How to use the macros:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code
Code:
Option Explicit
Public dTime As Date
Sub ValueStore()
Dim dTime As Date
Range("B" & Cells(Rows.Count).Row).End(xlUp).Offset(1, 0).Value = Range("A1").Value
Call StartTimer
End Sub
Sub StartTimer()
dTime = Now + TimeValue("00:00:05")
Application.OnTime dTime, "ValueStore", Schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime dTime, "ValueStore", Schedule:=False
End Sub
5. Get out of VBA (Press Alt+Q)
6. Save your sheet
7. Click on the Control Toolbox Command Button icon
8. Draw a button on your worksheet
9. Right-click the button and select Properties
10. Change the Caption to Start Timer
11. Right-click the button and select View Code
12. Paste in this code for the commad button:
Code:
Private Sub CommandButton1_Click()
Call StartTimer
End Sub
13. Switch back to your spreadsheet
14. Repeat steps 7-12 to create a Stop Timer button
Code:
Private Sub CommandButton2_Click()
Call StopTimer
End Sub
15. Press Alt-Q to close the VBEditor and save your sheet
Try the new buttons.
Like this thread? Share it with others