How to Create an Excel Timer with Start and Stop Buttons Using VBA
Question details
The user needs to build an Excel worksheet timer with Start and Stop buttons to track time across multiple tasks sequentially and record the elapsed time in the next row automatically.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Tracking elapsed time for specific tasks (e.g., five sequential tasks) and recording the time automatically into rows without calculating a grand total.
- Observed behavior
- The user requires a reliable VBA method and form buttons to log the timer, bypassing sum logic. Some users also reported errors when pasting VBA code into the Automate > New Script section.
Ensure you have the Developer tab enabled in your spreadsheet ribbon, as you will need access to the Visual Basic Editor (VBE) and form controls. Save your file as a Macro-Enabled Workbook (.xlsm) to prevent losing your VBA code.
Create Start and Stop Macros Using Visual Basic
Write a VBA script to control the timer and link it to clickable form buttons on your worksheet.
By utilizing VBA, you can define a public variable to hold the start time and then calculate the time difference when the stop button is clicked. The result can then be pushed to the next available empty row.
Press Alt + F11 on your keyboard to open the Visual Basic Editor (VBE) interface.
Click on Insert in the top menu and select Module to create a new standard module where the VBA code will live.
Enter your VBA code to define a Start procedure (recording the current time) and a Stop procedure (calculating elapsed time and writing it to the next empty row using the Offset method).
Close the VBE and return to your worksheet. Navigate to the Developer tab, click Insert, and choose Button (Form Control). Draw two buttons on your sheet.
Right-click the first button, select Assign Macro, and choose your Start procedure. Repeat the process for the second button, linking it to your Stop procedure.

Use WPS Spreadsheet to Run VBA Macros and Timers
WPS Office fully supports VBA macros, allowing you to create custom timers, automate task tracking, and insert form buttons just like you would in Microsoft Excel.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing spreadsheet document.
- 2. Enable Developer Tools: Navigate to the Tools tab and click Developer to access macro and form settings.
- 3. Add VBA Code: Click the VBA Editor button (or press Alt + F11) to paste your Start and Stop timer code into a new module.
- 4. Insert Form Buttons: Use the Insert drop-down menu in the Developer tab to add Start and Stop buttons to your sheet, then assign your macros.

Frequently Asked Questions
Why does my timer VBA code give an error when using Automate > New Script?
The 'Automate > New Script' feature uses Office Scripts (TypeScript), which is completely different from VBA. To use VBA code, you must open the Visual Basic Editor using Alt + F11 in the desktop version of Excel or WPS Spreadsheet.
How do I record the elapsed time to the next empty row automatically?
In your Stop macro, you can use the VBA End(xlUp) method to find the last used row in your target column, and then add an offset of 1 (Offset(1, 0)) to write the elapsed time value into the next blank row.
Can I use this timer without calculating a grand total?
Yes. Your macro can be programmed simply to output the individual elapsed time for each cycle into the next task row, without including any sum or grand total calculation logic in the script.
Will I lose my timer macro when I close the workbook?
You will lose the code if you save the file in standard .xlsx format. You must save the document as an Excel Macro-Enabled Workbook (.xlsm) to preserve the VBA module and your button assignments.




