A
Adrian
I'm trying to write a VBA function to count the number of matches to two
criteria.
In a worksheet I can use SUMPRODUCT(--(range1="value1"),--(range2="value2"))
but I can't make it work in VBA.
range1 and range2 and value1 are variables, value2 is a string constant.
answer = Application.WorksheetFunction.SumProduct("--(" & range1 & "=""" &
value1 & """)", "--(" & range2 & "=""value2"")")
I am getting type mismatch errors. I suspect the problem is range1 and
range2 ; on a worksheet they are in the form A2:A300 but in VBA they aren't.
How to sort this out? Or is there a better method?
criteria.
In a worksheet I can use SUMPRODUCT(--(range1="value1"),--(range2="value2"))
but I can't make it work in VBA.
range1 and range2 and value1 are variables, value2 is a string constant.
answer = Application.WorksheetFunction.SumProduct("--(" & range1 & "=""" &
value1 & """)", "--(" & range2 & "=""value2"")")
I am getting type mismatch errors. I suspect the problem is range1 and
range2 ; on a worksheet they are in the form A2:A300 but in VBA they aren't.
How to sort this out? Or is there a better method?