How to Create a Button-Controlled Stopwatch Timer in Excel VBA
Question details
The user needs to create a button-controlled VBA stopwatch timer in Excel to track elapsed match times across multiple tables.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Tracking active match durations using buttons embedded directly within specific table brackets on the spreadsheet.
- Observed behavior
- Requires a method to link start and stop VBA procedures to properly sized form controls inside the worksheet to display time in specific cells.
Ensure that the Developer tab is enabled in your Excel ribbon and that you save your workbook as an Excel Macro-Enabled Workbook (.xlsm) to allow your timer scripts to run.
Write VBA Code and Assign to Form Control Buttons
Create standard modules for starting and stopping a timer using the Application.OnTime method, then link these macros to inserted button controls.
A VBA stopwatch typically relies on a repeating loop or the Application.OnTime method to update a cell's value every second. You can trigger this process using standard Form Controls.
To make the interface clean, you can resize the inserted buttons so they fit perfectly within your table brackets.
Press Alt + F11 to open the Visual Basic for Applications editor. Go to Insert > Module in the top menu to create a new blank script area.
Paste your custom VBA code for the stopwatch. You will typically need one sub-procedure to start the timer (using Application.OnTime) and another to stop it.
Close the VBA editor and go to the Developer tab on the Excel ribbon. Click Insert, select the Button icon under Form Controls, and draw two buttons on your sheet.
Right-click the first button, choose Assign Macro, and select your 'Start' script. Repeat this for the second button, linking it to your 'Stop' script.
Hold down the Alt key while dragging the edges of your buttons. This snaps the buttons to the cell grid, ensuring they fit perfectly inside your specific table areas.

Run and Edit VBA Macros Seamlessly in WPS Spreadsheets
WPS Spreadsheets provides excellent compatibility with Microsoft Excel's VBA macros. You can create, edit, and run your button-controlled stopwatch timers smoothly within the WPS environment.
- 1. Download and Install: Download WPS Office and ensure the VBA module is enabled for your installation.
- 2. Open your Macro-Enabled Workbook: Launch WPS Spreadsheets and open your .xlsm file. WPS perfectly retains your VBA code, module structure, and button layouts.
- 3. Test the Stopwatch Timer: Click the Start button you created. The VBA engine in WPS Spreadsheets will execute the timer script seamlessly, updating the cell values just like in Excel.

Frequently Asked Questions
How do I resize a macro button to fit exactly inside an Excel cell?
To make a button fit perfectly inside a cell, hold down the Alt key while dragging the sizing handles of the button. The Alt key enables the 'Snap to Grid' feature, automatically aligning the button's edges with the cell borders.
Why isn't my VBA stopwatch updating the cell time continuously?
A VBA stopwatch usually relies on the Application.OnTime method to schedule recursive updates. If you are actively editing a cell, clicking the ribbon, or running another macro, Excel suspends background VBA processes, which pauses the timer.
Can I run multiple stopwatches at the same time in Excel?
Yes, but it requires more advanced VBA scripting. Standard Application.OnTime loops might conflict if they share the same global variables. You must assign distinct variables and scheduled tasks for each timer, or utilize class modules for cleaner execution.




