A1到AN是横向输入?应该是纵向呀!
Sub 按钮1()
Cells(Range("a65536").End(xlUp).Row + 1, 1) = 1
End Sub
Sub 按钮2()
Cells(Range("a65536").End(xlUp).Row + 1, 1) = 2
End Sub
插入一个按钮控件,把下面的代码贴进去,注意你的button的名字替换掉Private Sub CommandButton1_Click()中的CommandButton1
Option Explicit
Public buttonClickCount As Integer
Private Sub CommandButton1_Click()
buttonClickCount = buttonClickCount + 1
Worksheets("Sheet3").Cells(1, 5).value = Worksheets("Sheet1").Cells(buttonClickCount, 1).value
'MsgBox (buttonClickCount)
End Sub
注意每次重新打开excel表格,按钮计数才会重置为零
考点是静态变量,代码如下:
Option Explicit
Sub x()
Static x
x = x + 1
Sheets("sheet2").Range("c3") = Sheets("sheet1").Cells(x, 1)
End Sub