Aug 15, 2009

Counting number of “X” in a Column

You want to analyze and know the total number of “XYZ” exist in Column B

Use the following VBA code:

Sub GetNumOfXYZ()
searchKey = “XYZ”
Set rng = Columns(”B”)
MsgBox WorksheetFunction.CountIf(rng, searchKey)
End Sub

No comments: