WorksheetFunction.CountIf Method

Counts the number of cells within a range that meet the given criteria.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function CountIf ( _
    Arg1 As Range, _
    Arg2 As Object _
) As Double
'Usage
Dim instance As WorksheetFunction
Dim Arg1 As Range
Dim Arg2 As Object
Dim returnValue As Double

returnValue = instance.CountIf(Arg1, Arg2)
double CountIf(
    Range Arg1,
    Object Arg2
)

Parameters

  • Arg2
    Type: System.Object

    The criteria in the form of a number, expression, cell reference, or text that defines which cells will be counted. For example, criteria can be expressed as 32, "32", ">32", "apples", or B4.

Return Value

Type: System.Double
Returns Double.

Remarks

You can use the wildcard characters, question mark (?) and asterisk (*), for the criteria. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.

See Also

Reference

WorksheetFunction Interface

WorksheetFunction Members

Microsoft.Office.Interop.Excel Namespace