VBA & Macro Problems

Create a Conditional Navigation Button for an Excel Form with VBA

Amos GikundaAmos Gikunda Nov 18, 2026 869 views

Question details

Create a button that checks required Excel form fields before navigating to another worksheet.

Create a Conditional Navigation Button for an Excel Form with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants to move from a form to the next worksheet only after required cells are complete, without using the HYPERLINK function.
Observed behavior
The button should select the first empty required cell or activate the destination worksheet when all required cells are filled.
Before you start

Open the workbook in desktop Excel and identify the form sheet, destination sheet, and required cell addresses. Make sure you can use the Developer tab and enable macros for this workbook if you trust its source.

Solution 1Recommended

Assign a VBA validation macro to an Excel form button

Use this method to check required cells in order and navigate only when they are complete.

1
Open the VBA editor

In Excel, select Developer > Visual Basic. In the editor, select Insert > Module to add a standard module to the workbook.

2
Add the macro

Paste this code into the module: Sub GoToNextStep() Dim formSheet As Worksheet Dim nextSheet As Worksheet Set formSheet = ThisWorkbook.Worksheets("Form") Set nextSheet = ThisWorkbook.Worksheets("details") formSheet.Activate If formSheet.Range("I10").Value = "" Then formSheet.Range("I10").Select ElseIf formSheet.Range("I14").Value = "" Then formSheet.Range("I14").Select Else nextSheet.Activate nextSheet.Range("A1").Select End If End Sub

3
Customize the references

In the code, replace "Form" and "details" with your worksheet names and change I10, I14, and A1 to the appropriate cell addresses. Add more ElseIf checks before Else for any other required fields.

4
Assign the macro

Return to Excel and right-click an existing shape or form button, select Assign Macro, choose GoToNextStep, and select OK. Alternatively, use Developer > Insert > Button (Form Control) to create a button and assign the macro.

5
Save and test

Select File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). Click the button with each required field empty, then fill both fields and click it again to confirm that the destination sheet opens.

Assign a VBA validation macro to an Excel form button
Blank-field checks: The checks run in the order written and also treat a formula returning an empty string as blank. They do not validate the format or accuracy of entered values.
Free Microsoft Office alternative

Work with Excel Form Workbooks in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Excel workbooks. Its format compatibility can make moving existing files easier, but VBA macro support depends on the WPS edition and setup; verify your navigation macro before relying on it.

Open and edit Excel-format spreadsheets, including .xlsx workbooksUse a familiar interface to work with form fields and worksheet tabsMove existing spreadsheets into a lightweight office suiteAccess free spreadsheet editing alongside document and presentation tools
microsoft office alternative - wps office

Frequently Asked Questions

How do I add another required field to the macro?

In Developer > Visual Basic, add an ElseIf formSheet.Range("cell").Value = "" Then branch before the final Else, followed by formSheet.Range("cell").Select. Replace both cell references with the required address.

Why does the macro select the wrong empty field first?

The macro checks cells in the order of its If and ElseIf branches. In Developer > Visual Basic, rearrange those branches to match the order in which users should complete the form.

Why does the button not run the macro?

Right-click the button and select Assign Macro to confirm that GoToNextStep is assigned. Save the file as .xlsm and, if you trust the workbook, enable macros when Excel prompts you.

Can I use this VBA button in Excel for the web?

Excel for the web does not run VBA macros. Open the workbook in desktop Excel to assign and run the navigation macro.

How can I show the Developer tab in Excel?

In desktop Excel, open the ribbon customization settings and enable Developer. On Windows, use File > Options > Customize Ribbon and select the Developer check box.