I am trying to sum up data in 3 columns one by one and paste the total in next sheet in three cells. I have come up with the following code. It works fine a couple of times but then starts throwing the error: Run-time error '1004' Application-defined or object-defined error.
Sub test1()
Dim Counter As Integer
Counter = 1
For i = 1 To 3
Do Until ThisWorkbook.Sheets("Sheet1").Cells(Counter, i).Value = ""
ThisWorkbook.Sheets("Sheet1").Range(Cells(1, i), Cells(Counter, i)).Select
Counter = Counter + 1
Loop
Value1 = Application.WorksheetFunction.Sum(Selection)
ThisWorkbook.Sheets("Sheet2").Cells(1, i).Value = Value1
Next i
End Sub
On Error Goto
to see on which line the error is occurring? – psubsee2003