kweaver
Well-known Member
- Joined
- May 12, 2009
- Messages
- 2,940
- Office Version
- 365
What's wrong here?
Code:
Dim Arg1 As Range 'the range i want to sum
Dim Arg2 As Range 'criteria range
Dim Arg3 As Range 'the criteria (range)
Set Arg1 = Sheets("TextFile").Range("M5:N10000")
Set Arg2 = Sheets("TextFile").Range("K5:K10000")
Set Arg3 = Sheets("TextFile").Range("H5:H10000")
' get the sum of the drive time hours
For i = 5 To 8
Sheets("TextFile").Cells(i, 21) = Application.WorksheetFunction.SumIfs(Arg1, Arg2, Cells(i, 20).Value, Arg3, "Drive Time")
Next i