Reputation: 103
I am not getting the correct calculation for the following code. I am counting cells with value greater than 2 and greater than D1 in a range. I can't get this to calculate correctly with criteria >2.
Range("C1").Formula = "=COUNTIFS(A2:C10,"">2"",F2:F10, "">""&D1)"
Upvotes: 0
Views: 881
Reputation: 166980
From: http://office.microsoft.com/en-us/excel-help/countifs-function-HA010047494.aspx
"criteria_range2, criteria2, ... Optional. Additional ranges and their associated criteria. Up to 127 range/criteria pairs are allowed.
Important Each additional range must have the same number of rows and columns as the criteria_range1 argument. The ranges do not have to be adjacent to each other."
Your two ranges are different sizes. How you need to change your formula will depend on exactly what outcome you expect.
Upvotes: 1
Reputation: 19737
I think you have to separately compare each column like this:
Range("C1").Formula = _
"=COUNTIFS(A2:A10,"">2"",B2:B10,"">2"",C2:C10,"">2"",F2:F10,"">""&D1)"
Upvotes: 0