This code counts the number of cells in the selected range that meet a specific criteria
VBA Code:
Sub CountCellsByCriteria()
Dim cell As Range
Dim count As Integer
Dim criteria As String
count = 0
criteria = "Criteria"
For Each cell In Selection
If cell.Value = criteria Then
count = count + 1
End If
Next cell
MsgBox "Count: " & count
End Sub