I am currently trying to teach myself some basic excel vba and I am stuck on a sumifs.
I have two Worksheets (Sheet1 and Sheet2) in the same workbook. I am trying to have cells Sheet 1 D4:D20 sum up the data in sheet 2 based on two criteria. The first criteria (Y) is variable and stored in Sheet1 C4:C20, while the second criteria is E. Unfortunately, I keep getting errors when I try to calculate the last row. What I have so far is:
Sub Test_Sumifs()
Dim EndRow As Long
Dim i As Integer
EndRow = Cells(row.Count, "C").End(x1Up).row
Set SumRange = Worksheets("Sheet2").Range("D2:D17")
Set Criteria1 = Worksheets("Sheet2").Range("B2:B17")
Set Criteria2 = Worksheets("Sheet2").Range("C2:C17")
For i = 4 To EndRow
Cells(i, 4).Value = WorksheetFunction.SumIfs(SumRange, Criteria1, [C4], Criteria2, ["E"])
Next i
End Sub
I've looked around and tried various methods but can't figure out whats wrong.
Greatly appreciate your help,
End(xlUp)
with an L rather than a 1. – SJRrow.Count
berows.Count
? – Mistella