VBA & Macro Problems

How to Use an Excel Slicer to Navigate Between Worksheets

Ayan MasoodAyan Masood Nov 10, 2026 868 views

Question details

Configure an Excel slicer to act as a visual navigation menu that switches between different worksheet tabs based on the user's selection.

How to Use an Excel Slicer to Navigate Between Worksheets
Product
Excel
Device & OS
not provided
Scenario
A user wants to create an interactive dashboard where selecting an item in a slicer automatically jumps to a corresponding worksheet.
Observed behavior
By default, slicers only filter table or PivotTable data. The goal is to bind the slicer selection to a macro or hyperlink that actively changes the currently active worksheet.
Before you start

Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm), as VBA code is required to capture the slicer selection and trigger the worksheet navigation.

Solution 1Recommended

Use VBA and the PivotTableUpdate Event for Navigation

By creating a foundational PivotTable and capturing the update event triggered when a slicer is clicked, you can use VBA to activate specific worksheets automatically.

Since slicers do not have their own click events in Excel VBA, you must link the slicer to a PivotTable. Whenever the slicer is clicked, it updates the PivotTable, triggering a Worksheet_PivotTableUpdate event that your VBA code can intercept.

1
Create a foundational PivotTable

Select a data range containing a column with the exact names of your destination worksheets. Go to Insert > PivotTable. Place this PivotTable on your main dashboard sheet and add the worksheet name field to the PivotTable.

2
Insert the navigation slicer

Click anywhere inside your newly created PivotTable. Go to the PivotTable Analyze tab on the ribbon, click Insert Slicer, check the box for your worksheet names field, and click OK.

3
Add the VBA event macro

Press Alt + F11 to open the VBA Editor. In the Project Explorer pane on the left, double-click the worksheet that contains your PivotTable and Slicer. Paste a Worksheet_PivotTableUpdate macro that iterates through the SlicerCache to find the selected item, and uses Sheets(selectedName).Activate to navigate to the target sheet.

Use VBA and the PivotTableUpdate Event for Navigation
Match Worksheet Names Perfectly: The text values inside your slicer must perfectly match the actual tab names of your worksheets. Any mismatch in spelling or extra spaces will cause the VBA script to throw a 'Subscript out of range' error.
Advanced Data Management

Easily Build Interactive Dashboards with WPS Spreadsheet

WPS Office provides robust, built-in support for PivotTables, Slicers, and VBA macros. You can execute custom VBA scripts to navigate between worksheets seamlessly while enjoying a highly intuitive interface.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open your .xlsm file containing the dashboard data.
  2. 2. Insert PivotTable and Slicer: Navigate to the Insert tab, create a PivotTable, and click Slicer to generate your visual navigation menu.
  3. 3. Add the VBA code: Enable the Developer tab, open the VBA Editor, and paste your PivotTableUpdate macro to handle the worksheet transitions.
Full compatibility with Microsoft Excel .xlsx and .xlsm formatsComprehensive VBA macro support for advanced dashboard automationFree, lightweight, and fast-loading office suiteFamiliar user interface requiring no learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why is my VBA code not triggering when I click the slicer?

Slicers do not have native click events in VBA. Your macro must be placed within the specific Worksheet module where the linked PivotTable resides, and it must use the Worksheet_PivotTableUpdate event to detect the slicer click.

Can I use this method to navigate to hidden worksheets?

Yes, but your VBA macro must first unhide the worksheet by setting its Visible property to xlSheetVisible before attempting to activate it. If you try to activate a hidden sheet directly, Excel will return an error.

How do I prevent multiple worksheet selections in the slicer?

To ensure accurate navigation, users should only select one item at a time. While you cannot physically disable the multi-select button on a slicer without complex APIs, you can add an error-handling check in your VBA code (e.g., checking if SlicerItems.Selected count is greater than 1) and prompt the user to select only one destination.

Why do I get a 'Subscript out of range' error when the macro runs?

This error typically occurs when the name selected in the slicer does not perfectly match any existing worksheet tab name. Check your source data for typos, trailing spaces, or differences in capitalization compared to your actual worksheet tabs.