Hi everyone,
I am completely new to Excel VBA so I am really hoping I can get some help *thank you in advance*.
I have an excel worksheet that has different string values in the cells and I have to specifically count when the values "NSW" are found beside each other (i.e. NSW, NSW) in the excel sheet. I have only created a function so far (not sure if it is right...) but I I really need to do is create a command button that would show the results of the count in a message box, but I am stuck. Any help would be greatly appreciated!
Here is what I have so far:
Function CountIfAll(Crit1, Crit2, Rng As Range) As Long
Dim rCell As Range
CountIfAll = 0
For Each rCell In Rng
If rCell = Crit1 And rCell.Offset(, 1) = Crit2 Then
CountIfAll = CountIfAll + 1
End If
Next rCell
End Function
Bookmarks