[Table of Contents] [docx version]

SpreadsheetML Reference Material - Table of Contents

COUNTIF

Syntax:

COUNTIF ( cell-range , selection-criteria )

Description: Counts the number of cells in a specified range of cells, whose values meet the specified criteria.

Arguments:

Name

Type

Description

cell-range

reference

Designates the range of cells to be inspected.

selection-criteria

number, expression, reference, text

Designates the cells to be counted. In the case of text, selection-criteria can consist of any comparison operator followed by the operand against which each cell's value is to be compared. selection-criteria can include one or more wildcard characters, question mark (?) and asterisk (*). A question mark matches any single character; an asterisk matches any sequence of characters. To search for a question mark, asterisk, or tilde character, prefix that character with a tilde (~).

 

Return Type and Value: number – The number of cells in the range specified that meet the criteria.

[Example: Given that A1, B1, C1, and D1, respectively, contain the values 3, 10, 7, and 10

COUNTIF(A1:D1,"=10") results in 2
COUNTIF(A1:D1,">5") results in 30
COUNTIF(A1:D1,"<>10") results in 2

Given that A2, B2, C2, and D2, respectively, contain the values apples, oranges, grapes, and melons

COUNTIF(A2:D2,"*es") results in 3
COUNTIF(A2:D2,"??a*") results in 2
COUNTIF(A2:D2,"*l*") results in 2

end example]