我正在尝试将 3 列中的数据一一汇总,并将总数粘贴到下一张表中的三个单元格中。我想出了以下代码。它工作正常几次,但随后开始抛出错误:运行时错误'1004'应用程序定义或对象定义错误。
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