Hi,
I'm having troubles turning this Excel formula:
=SUM(SUMIF(B3:B25,{110.5,110.6},C3:C25))
into this VBA code:
With ActiveSheet
WorksheetFunction.Sum(WorksheetFunction.SumIf(Range(.Cells(3, 2), .Cells(25, 2)), {110.5, 110.6}, Range(.Cells(3, 3), .Cells(25, 3))))
End with
The problem lies with the {} braces; vba doesn't recognize them. The formula needs to sum a range if the adjacent left cells equal 110.50 or 110.60.
I could use sumproduct:
=SUMPRODUCT((B3:B25={110.5,110.6})*C3:C25)
but once again the {} are used. Any ideas on how I can get around using {} within VBA? I'm not sure if evaluate will work since the range will be changed thousands of times using a variable within .Cells(variable, 2).
Thank you!
Bookmarks