VBA code for array formula


Posted by brian on February 01, 2000 8:09 AM

I am attempting to code in VBA a countif formula that
has 2 conditions--Count if A and B are true. I have
looked over some of the previous messages and have not
sene references to VBA code. Could someone give a
reference?

THanks.



Posted by Celia on February 01, 2000 5:18 PM

Brian
Let's say that you want to count how many times "Something" appears in Column A if "Whatever" appears in Column B.
The following macro will do it and put the result in cell C1
Celia

Sub CountMatchingCriteria()
Dim R As Integer, entry As Range
For Each entry In Range("A:A")
If entry = "Something" And entry.Offset(0, 1) = "Whatever" Then
R = R + 1
End If
Next
Range("C1").Value = R
End Sub