Reputation: 1
I am not able to correct this code. It is throwing error in line where i have used sumifs formula. Whats wrong in this?
Sub try()
Dim Arg1 As Range
Dim Arg2 As Range
Dim Arg3 As Range
Dim Arg4 As Range
Set Arg1 = Sheets("Raw Data_All Products").Range("O:O")
Set Arg2 = Sheets("Raw Data_All Products").Range("J:J")
Set Arg3 = Sheets("Raw Data_All Products").Range("B:B")
Set Arg4 = Sheets("Raw Data_All Products").Range("A:A")
Sheets("Sheet2").Cells(12, c).Value =
Application.WorksheetFunction.SumIfs(Arg1, Arg2, "SM Parcels", Arg3, "2015",
Arg4, "1")
End Sub
Upvotes: 0
Views: 269
Reputation: 14580
Issue line: Sheets("Sheet2").Cells(12, c).Value =
You have a syntax issue with the Cells
object. The correct syntax is Cells(Row Index, Col Index)
where index is a number (or col letter houesd in quotes).
Row Index is self explanatory (1 = 1
).
Column Index: A = 1
, B = 2
, C = 3
or A = "A"
, B = "B"
, C = "C"
If your goal is to have the SUMIF
value displayed in cell C12
, you can try any of the three equal alternatives below.
1) Sheets("Sheet2").Cells(12, "C").Value =
2) Sheets("Sheet2").Cells(12, 3).Value =
3) Sheets("Sheet2").Range("C12").Value =
Upvotes: 1