How to Create Next and Previous Buttons for an Excel Data Validation List
Question details
The user wants to navigate through an Excel data validation list using clickable Next and Previous buttons instead of using the standard dropdown arrow.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating an interactive form or dashboard where users can click buttons to cycle through values in a dropdown list.
- Observed behavior
- The user has formulas calculating the previous and next values in cells P2 and P4, and needs a way to place these calculated results into the target cell P3 upon button clicks.
Ensure that the Developer tab is enabled in your ribbon and that your workbook is saved as a Macro-Enabled Workbook (.xlsm) so the VBA code can execute properly.
Use VBA Code to Assign Button Actions
Create Form Control buttons and assign a simple VBA script to update the target cell with the next or previous values automatically.
By leveraging Excel's VBA, you can easily pull the calculated 'Next' and 'Previous' values from auxiliary cells and push them into your main data validation cell. This method relies on cells P2 and P4 containing formulas that dynamically calculate what the previous and next items are based on the current selection in P3.
Go to the Developer tab on the ribbon, click Insert, and select the Button icon under Form Controls. Draw two buttons on your worksheet and label them 'Next' and 'Previous'.
Press ALT + F11 to open the Visual Basic for Applications editor. In the top menu, click Insert and select Module to create a new blank module.
Paste the following code into the module window: Private Sub NextBtn_Click() Range("P3") = Range("P4") End Sub Private Sub PrevBtn_Click() Range("P3") = Range("P2") End Sub
Close the VBA editor. Right-click the 'Next' button, select Assign Macro, and choose 'NextBtn_Click'. Repeat this process for the 'Previous' button, assigning it the 'PrevBtn_Click' macro.

Easily Run VBA Macros in WPS Office
WPS Spreadsheet fully supports VBA macros and form controls out of the box, allowing you to create interactive dashboards with Next and Previous buttons just like you do in Microsoft Excel.
- 1. Open your Workbook: Open your Excel file in WPS Spreadsheet and navigate to the Developer tab.
- 2. Insert Buttons: Click Insert > Button (Form Control) to draw the Next and Previous buttons on your sheet.
- 3. Write and Assign VBA: Open the built-in VBA editor, paste your navigation code, and assign the macros to your newly created buttons.

Frequently Asked Questions
Why are my VBA buttons not doing anything when clicked?
Check if macros are enabled in your workbook settings. Go to the Trust Center or Macro Security settings and ensure macros are allowed. Also, verify that the macro is correctly assigned to the button by right-clicking it and selecting 'Assign Macro'.
Can I use this method if my data validation list is in a different cell?
Yes. Simply change the cell references in the VBA code. Replace 'P3' with your target cell, and 'P2' or 'P4' with the cells that contain your previous and next value formulas.
How do I calculate the previous and next values in cells P2 and P4?
You can use a combination of INDEX and MATCH functions. For example, use MATCH to find the current item's position in the source list, then use INDEX to return the item at position + 1 (for Next) or position - 1 (for Previous).
Does this macro work in WPS Office as well?
Yes, WPS Spreadsheet supports VBA macros perfectly. You can use the exact same code and form controls to achieve this functionality seamlessly in WPS Office.




