Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 单击宏按钮时如何在表2上创建时间戳记录和说明_Excel_Excel 2010_Vba - Fatal编程技术网

Excel 单击宏按钮时如何在表2上创建时间戳记录和说明

Excel 单击宏按钮时如何在表2上创建时间戳记录和说明,excel,excel-2010,vba,Excel,Excel 2010,Vba,我已经着手创建一个工作表,可以方便地跟踪硬币的进出。 我已经能够源一个简单的宏来创建按钮,这将添加我需要的金额 Sub bPlus10bag() Range("B2") = Range("B2") + 10 End Sub 我希望每次单击此宏按钮时,第2页都会有一个按钮按下日期和时间的运行列表,并与此相邻的是按下的宏的名称,即“bPlus10bag”,稍后修改名称 我已经搜索了无数页来找到这个,但最多只能找到我需要的部分内容,而且我不擅长编写自己的代码 我正在使用Excel 2010 如果

我已经着手创建一个工作表,可以方便地跟踪硬币的进出。 我已经能够源一个简单的宏来创建按钮,这将添加我需要的金额

Sub bPlus10bag()

Range("B2") = Range("B2") + 10

End Sub
我希望每次单击此宏按钮时,第2页都会有一个按钮按下日期和时间的运行列表,并与此相邻的是按下的宏的名称,即“bPlus10bag”,稍后修改名称

我已经搜索了无数页来找到这个,但最多只能找到我需要的部分内容,而且我不擅长编写自己的代码

我正在使用Excel 2010

如果需要,很乐意提供更多细节。

怎么样

Sub bPlus10bag()
Dim wslog As Worksheet
Dim ws As Worksheet
Dim lrow As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
Set wslog = ThisWorkbook.Sheets("Sheet2")

'change the value in sheet 1
ws.Range("B2") = ws.Range("B2").Value + 10
' find the last row of column A in Sheet 2 and add 1 to get the
' row number of the next empty cell
lrow = wslog.Cells(Rows.Count, "A").End(xlUp).Row + 1
' write the current date and time into the cell
wslog.Range("A" & lrow) = Now
' write the current macro name into the cell
wslog.Range("B" & lrow) = "bPlus10bag"

End Sub