How to Operate Excel Spin Buttons with a Keyboard
Question details
The user wants to adjust timesheet values in 15-minute increments using keyboard arrow keys instead of clicking multiple Excel spin-button controls.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Entering time logs in an Excel timesheet while frequently switching between Excel and Outlook using the keyboard.
- Observed behavior
- Adjusting values currently requires clicking individual spin buttons with a mouse, which is inefficient when multitasking via keyboard.
Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that macros are enabled in your spreadsheet security settings before adding the VBA event.
Replace Spin Buttons with a Keyboard-Friendly VBA Event
Instead of using physical spin button controls, implement a Worksheet_SelectionChange VBA macro that detects keyboard arrow key movements to adjust time increments automatically.
This approach eliminates the need for clicking multiple spin buttons. By mapping trigger columns to time columns, you can simply press the Up or Down arrow key in the adjacent cell to add or subtract 15 minutes.
The same logic can be seamlessly extended to multiple column pairs (such as D and C, F and E) within a single VBA procedure.
Delete the existing physical spin buttons from your spreadsheet. Select your target time columns (e.g., columns C, E, G, I, K) and format them as Time.
Right-click the worksheet tab at the bottom of your screen and select 'View Code' to open the Microsoft Visual Basic for Applications (VBA) editor.
In the worksheet module, set up a 'Worksheet_SelectionChange' event. Create logic to detect when a single cell in your trigger column (e.g., column D) is selected.
Write code so that moving the selection Up or Down increases or decreases the adjacent time cell in column C by 15 minutes, and then forces the active selection back to the original entry point.
Wrap your selection change code with 'Application.EnableEvents = False' at the start and set it to 'True' at the end. This prevents the macro from triggering an endless recursive loop when resetting the cursor position.
Automate Spreadsheets with WPS Office
WPS Spreadsheet provides powerful, built-in support for VBA macros, allowing you to create custom keyboard controls and automate time entries without relying on a mouse.
- 1. Open your Timesheet in WPS: Launch WPS Spreadsheet and open your existing timesheet document.
- 2. Access Developer Tools: Navigate to the Developer tab on the ribbon to manage or create new macros and VBA scripts.
- 3. Add Your Selection Code: Click the VBA Editor button, paste your 'Worksheet_SelectionChange' code into the appropriate sheet module, and save.
- 4. Save as Macro-Enabled: Save your file as an .xlsm (Macro-Enabled Workbook) to ensure your keyboard shortcuts remain active.

Frequently Asked Questions
Can I operate standard ActiveX spin buttons with a keyboard without using VBA?
Native ActiveX or Form Control spin buttons generally require mouse clicks or complex API hooks to bind to keyboard arrows when they don't have active focus. Replacing them with a worksheet selection event is the most reliable and user-friendly alternative.
How do I change the time increment from 15 minutes to 30 minutes in the macro?
In your VBA code, locate the addition or subtraction logic and update the time value being added. For example, change 'TimeValue("00:15:00")' to 'TimeValue("00:30:00")' or adjust the TimeSerial parameters accordingly.
Why does my cursor get stuck in an endless loop when I press an arrow key?
This occurs if 'Application.EnableEvents = False' is not called before your code selects the original cell to return the cursor. The cell selection triggers the Worksheet_SelectionChange event again automatically. Always re-enable events at the very end of your script.




