Hi Guys,
I am trying to generate a code using CountIfs function for more than one ranges. My code works well when selecting the ranges as shown below, :
Cells(3, 19).Value = Application.WorksheetFunction.CountIfs(Range("A1:C3"), "=" & 1, Range("B1:D3"), "=" & 1, Range("A2:C4"), "=" & 1, Range("B2:D4"), "=" & 1)
However, this form of the same line is not working for more than one ranges:
Cells(3, 19).Value = Application.WorksheetFunction.CountIfs(Range(Cells(3, 1), Cells(3, 3)), "=" & 1, Range(Cells(1, 2), Cells(3, 4)), "=" & 1, Range(Cells(2, 1), Cells(4, 3)), "=" & 1, Range(Cells(2, 2), Cells(4, 4)), "=" & 1)
Any suggestions on how to solve this?
Thanks