VBA & Macro Problems

Add Previous and Next Buttons to an Excel VBA UserForm

Ayan MasoodAyan Masood Nov 27, 2026 871 views

Question details

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

Add Previous and Next Buttons to an Excel VBA UserForm
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.
Before you start

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.

Solution 1Recommended

Navigate between two Excel VBA UserForms

Use each button's Click event to close the current form and show the other form.

1
Open the form editor

In Excel, open Developer > Visual Basic. In the Project Explorer, open the first UserForm, such as UserForm1.

2
Add the Next button

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.

3
Add the forward code

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.

4
Add the Previous button

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.

5
Test the navigation

Select UserForm1 in the Visual Basic editor and choose Run > Run Sub/UserForm. Click Next, then Previous, to verify that both forms open.

Navigate between two Excel VBA UserForms
Form values are reset: Unload closes the current form and discards its unsaved control values. If those values must persist, save them separately before navigating.
Free Microsoft Office alternative

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.

Open and edit common Microsoft Excel formats, including XLSXUse a familiar spreadsheet interface for everyday workbook tasksWork in a lightweight office suite with free featuresReview spreadsheet data alongside your UserForm-based Excel workflows
microsoft office alternative - wps office

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.