How to Select a Worksheet by Name Using Excel VBA Macro
Question details
The user wants to create a macro that navigates to a specific worksheet dynamically, using a sheet name stored in a designated cell.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Creating a dynamic navigation button that changes its target worksheet when a cell's value is updated.
- Observed behavior
- A VBA script is needed to read the worksheet name from a cell (e.g., B1) and select that corresponding sheet automatically.
Ensure that you have enabled the Developer tab in your spreadsheet settings and saved your file as a Macro-Enabled Workbook (.xlsm) to allow VBA code to run properly.
Use VBA Code to Select a Worksheet Based on Cell Value
Write a simple VBA script that reads the target sheet name from a specific cell and jumps to it via a Form Control button.
This method uses a small VBA script combined with a Form Control button to create dynamic navigation. When you change the text in the reference cell, the button automatically links to the updated sheet name.
Press ALT + F11 on your keyboard to open the VBA Editor, then click 'Insert' > 'Module' to create a new code module.
Copy and paste the following code into the module window: Sub Jump2Sheet() On Error Resume Next Worksheets(Range("B1").Value).Select End Sub
Return to your spreadsheet, go to the Developer tab, click 'Insert', and select 'Button (Form Control)'. Draw the button on your sheet.
When the 'Assign Macro' dialog appears, select 'Jump2Sheet' from the list and click 'OK'. Test it by typing an existing sheet name into cell B1 and clicking your new button.
Easily Manage VBA Macros in WPS Office Spreadsheets
WPS Office Spreadsheets provides excellent support for VBA macros, allowing you to run and edit Excel scripts seamlessly. You can automate tasks and create dynamic worksheet navigation buttons just like in Microsoft Excel.
- 1. Open your macro-enabled file: Launch WPS Spreadsheets and open your existing .xlsm workbook.
- 2. Access the VBA Editor: Navigate to the Tools tab and click on the 'Macro' or 'VBA Editor' button to write your navigation code.
- 3. Assign and Execute: Insert a shape or form control button, right-click it, assign your dynamic worksheet selection macro, and test the navigation.

Frequently Asked Questions
Why is my VBA macro not navigating to the specified worksheet?
This usually happens if the text in your reference cell does not exactly match the actual sheet name (including spaces), or if macros are disabled in your workbook's security settings.
Can I use a cell from a different worksheet as the reference?
Yes. You can modify the code to reference a specific sheet, such as Worksheets(Sheets("Menu").Range("B1").Value).Select, so the macro always checks the 'Menu' sheet for the target name regardless of which sheet is currently active.
How do I add a Form Control button if the Developer tab is missing?
You first need to enable the Developer tab. Go to File > Options > Customize Ribbon, and check the box next to 'Developer' in the right pane. Once enabled, you can find the Insert Button option on the Developer tab.




