1
Private Sub CommandButton1_Click()

NextRow = 2

Sheets("data").Cells(NextRow, 2) = Now

Sheets("data").Cells(NextRow, 3) = Sheets("sheet1").Cells(NextRow, 2)

Sheets("data").Cells(NextRow, 4) = ThisWorkbook.Sheets("Sheet1").Range("b3")

Sheets("data").Cells(NextRow, 5) = ThisWorkbook.Sheets("Sheet1").Range("b4")

Sheets("data").Cells(NextRow, 6) = ThisWorkbook.Sheets("Sheet1").Range("b5")

Sheets("data").Cells(NextRow, 7) = ThisWorkbook.Sheets("Sheet1").Range("b6")

Sheets("data").Cells(NextRow, 8) = ThisWorkbook.Sheets("Sheet1").Range("b7")

Sheets("data").Cells(NextRow, 9) = ThisWorkbook.Sheets("Sheet1").Range("b8")

Sheets("data").Cells(NextRow, 10) = ThisWorkbook.Sheets("Sheet1").Range("b10")

Sheets("data").Cells(NextRow, 11) = ThisWorkbook.Sheets("Sheet1").Range("b11")

Sheets("data").Cells(NextRow, 12) = ThisWorkbook.Sheets("Sheet1").Range("b12")
End Sub

这是我的代码。每当我继续赋予价值时,它就会被覆盖。如何改变它?如何在单独的行中输入?

4

1 回答 1

1

您可以弹出一个小循环以发现下一个空行,例如(未经测试!):

NextRow=2
do until Sheets("data").Cells(NextRow,2) = ""
    NextRow = NextRow + 1
Loop
于 2013-05-14T15:19:30.980 回答