Add Previous and Next Buttons to an Excel VBA UserForm
Question details
Add buttons to an Excel VBA UserForm so users can move to another form or worksheet and return to the previous form.

- Product
- Microsoft Excel VBA UserForms
- Device & OS
- not provided
- Scenario
- A workbook uses UserForms as screens and needs Previous and Next navigation.
- Observed behavior
- Users should be able to click a button to open the next form or a worksheet and use a return button to go back.
Open the workbook in desktop Excel and make sure the destination UserForms or worksheet already exist. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros only if you trust the file.
Navigate between two Excel VBA UserForms
Use each button's Click event to close the current form and show the other form.
In Excel, open Developer > Visual Basic. In the Project Explorer, open the first UserForm, such as UserForm1.
Select CommandButton in the Toolbox and draw it on UserForm1. In the Properties window, set its Caption to Next, then double-click the button to create its Click event.
Inside the generated Click procedure, add `Unload Me` followed by `UserForm2.Show` on the next line. Replace UserForm2 with the destination form's actual name.
Open UserForm2, add a CommandButton with the Caption Previous, and double-click it. Inside its Click procedure, add `Unload Me` followed by `UserForm1.Show` on the next line.
Select UserForm1 in the Visual Basic editor and choose Run > Run Sub/UserForm. Click Next, then Previous, to verify that both forms open.

Open a worksheet from a UserForm and return
Use a form button to activate a worksheet and a worksheet button to reopen the form.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Excel files. It can help you move everyday spreadsheet work between office suites, but it does not fix Excel VBA UserForm navigation.

Frequently Asked Questions
Where do I put the code for a UserForm button?
In Developer > Visual Basic, open the UserForm and double-click the button. Place the navigation statements inside the Click procedure that appears.
How do I find the correct UserForm name?
Select the form in the Visual Basic editor and check its (Name) property in the Properties window. Use that name in the Show statement, such as `UserForm2.Show`.
Will Previous restore the values I entered on the first form?
Not with the Unload examples above. Save the values separately before unloading the form if you need to restore them when it opens again.
Why won't my worksheet navigation code activate the sheet?
Check that the name in `ThisWorkbook.Worksheets("Sheet1")` matches the worksheet tab and that the sheet is visible. The example looks for the sheet in the workbook containing the code.
What file type should I use for the VBA code?
In Excel, choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm) so the workbook can retain its VBA code.




