Good day to you all
The sumproduct formula is working perfect but since ranges I set in the code are dynamic I am facing a problem to get it work. I tried to google for a solution but without success. I hope you can help. Here is part of the code
The sumproduct formula is working perfect but since ranges I set in the code are dynamic I am facing a problem to get it work. I tried to google for a solution but without success. I hope you can help. Here is part of the code
VBA Code:
Dim PyFields, Amounts, rng As Range
Dim ReportSht As Worksheet
Set ReportSht = Sheets("PR report")
With ReportSht
Set PyFields = .Range(.Cells(2, 4), .Cells(2, LC))
Set Amounts = .Range(.Cells(3, 4), .Cells(LR, LC))
End With
For each rng in Range(xxxx)
rng.Offset(0,1).Value = Application.Evaluate("SumProduct((" & PyFields.Address & " = """ & rng.Value & """)," & Amounts.Address & ")")
next