I have a worksheet that has almost 500,000 lines of data. I want to sum up all the data for each day.
My dates are stored in the format dd/mm/yyyy and are in column M, my values to be summed up are in column H...
and my output should show in column N...
My code so far doesn't seem to work mind once i get to my For/Next statement any ideas?
My dates are stored in the format dd/mm/yyyy and are in column M, my values to be summed up are in column H...
and my output should show in column N...
My code so far doesn't seem to work mind once i get to my For/Next statement any ideas?
Code:
Sub Fuel******()
Dim WS As Worksheet
Dim MaxRow As Long, I As Long
Dim Tot As Double
Dim Dte As String
Set WS = Sheets("Diesel Collaboration")
WS.Range("M3").Select
MaxRow = WS.Range("M" & WS.Rows.Count).End(xlDown).Row
Tot = 0
WS.Range("L:L").ClearContents
Sheets("Diesel Collaboration").Columns(1).Copy
Sheets("Diesel Collaboration").Columns(12).PasteSpecial xlPasteValues
WS.Range("N4:N1048576").ClearContents
Dte = WS.Cells(4, "M")
For I = 1 To MaxRow + 1
If WS.Range("M" & I) <> Dte Then
WS.Cells(I - 1, "H") = Tot
Dte = WS.Cells(I, "M")
Tot = 0
End If
Tot = Tot + Val(WS.Cells(I, "H"))
Next I
MsgBox ("Totals inserted in Col M by date successfully.")
End Sub