Sub test()
'Dim total(1 To 9) As Variant
ReDim total(1 To 9) As Variant
For i = 1 To 9
total(i) = Application.WorksheetFunction.SumIf(Sheets("Sheet2").Range(Cells(3, 3), Cells(i, 3)), ">" & _
Sheets("Sheet2").Range(Cells(3, 6), Cells(i, 6))-60, _
Sheets("Sheet2").Range(Cells(3, 4), Cells(i, 4)))
Next i
End Sub
Can anyone tell why i keep getting this error although i am using variant for my array? everything seems fine to me. What i am trying to do is to deduct 60 days from the date in the cells, then sum up the amount between the initial date and deducted date. so it would be like: enter image description here