-
Create a new module in your VBE and stick this in there:
Sub capturetime() Dim timeWS As Worksheet Dim timeRange As Range 'Change "Sheet3" to whatever worksheet is your click log Set timeWS = ThisWorkbook.Sheets("Sheet3") 'find the last cell in column A of your log Set timeRange = timeWS.Range("A" & timeWS.Rows.Count).End(xlUp).Offset(1) 'Write which button was clicked in column A timeRange.Value = Application.Caller 'Write the time in column B timeRange.Offset(, 1).Value = Now() End Sub
- Edit the values as necessary in that code.
- Create a button using Developer>>(Controls)Insert. Find the button in there. The “Form” button is fine.
- Draw the button on the screen somewhere. And, when it prompts you to assign a macro, choose “capturetime”
This bit of VBA will grab the name of the button that was pressed and the time and write it to whatever worksheet you select as the your log. It’s pretty simple, so it shouldn’t be a bother to mess with it to fit your needs.
solved Excel button that writes down the time of clicking