I am trying to remove formulas from the excel template and include them as part of VBA code. This formula is applied to one cell for July 2019 and then it goes to same row next column Aug-2019. Once done for the current row it goes to next row for next product for July 2019 again and so on. The following is the SumIfs code. =SUMIFS('Stat Fcst Data'!J:J,'Stat Fcst Data'!$E:$E,'Stat Fcst Data $'!$E2,'Stat Fcst Data'!$F:$F,'Stat Fcst Data $'!$F2,'Stat Fcst Data'!$B:$B,'Stat Fcst Data $'!$B2)*'Stat Fcst Data $'!$D2
I have so far tried changing how I write range, criterias etc. like(cells(i11,j11),cells(i11,j11)),(cells(i11,j11),cells(i11,j11)).value Currently in my code I am using criteria variables.
Dim sumRange, criteria1, criteria2, criteria3 As Range
criteria1 = WB3.Worksheets("Stat Fcst Data").Range("E:E")
criteria2 = WB3.Worksheets("Stat Fcst Data").Range("F:F")
criteria3 = WB3.Worksheets("Stat Fcst Data").Range("B:B")
For i11 = Row51 To Row51 + NoOfRows
For j11 = 7 To Col52
sumRange = WB3.Worksheets("Stat Fcst Data").Range(Cells(2, j11),
Cells(100000, j11))
WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11, j11),
Cells(i11, j11)).Value = WorksheetFunction.SumIfs(sumRange _
, criteria1, WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11,
5), Cells(i11, 5)).Value _
, criteria2, WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11,
6), Cells(i11, 6)).Value _
, criteria3, WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11,
2), Cells(i11, 2)).Value) _
* WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11, 4),
Cells(i11, 4)).Value
Next j11
Next i11
My code looks at two similar data sets called - Stat Fcst Data and Stat Fcst Data $. The code should be matching apples with apples and oranges with oranges. Currently, it runs without error but, it is not calculating sumifs and multiply that with the price which is this - WB3.Worksheets("Stat Fcst Data $").Range(Cells(i11, 4), Cells(i11, 4)).Value