Counta with CountIf
Hi Jay
I'm not sure how to do this with Countif but the code below will do it
for.
Option Explicit
Dim MyCell, MyRng As Range
Dim CntJohn, CntWanda As Integer
Private Sub CommandButton1_Click()
CntJohn = 0
CntWanda = 0
Set MyRng = [A1:A200]
For Each MyCell In MyRng
If MyCell.Value = "John" And _
MyCell.Offset(0, 9).Value = "x" Then
CntJohn = CntJohn + 1
ElseIf MyCell.Value = "Wanda" And _
MyCell.Offset(0, 9).Value = "x" Then
CntWanda = CntWanda + 1
End If
Next MyCell
MsgBox "There were " & CntJohn & " John's" & vbNewLine & _
"in the list with an 'x' in the Column J" & vbNewLine & _
"And there were " & CntWanda & " Wanda's" & vbNewLine & _
"in the list with an 'x' in the Column J"
End Sub
I hope this helps
Steve
|