VBA & Macro Problems

How to Preserve Excel Slicer Multi-Select Settings with VBA

Huda QurayshiHuda Qurayshi Nov 2, 2026 868 views

Question details

The user needs a method to automatically enable the slicer multi-select button whenever an Excel workbook is opened.

How to Preserve Excel Slicer Multi-Select Settings with VBA
Product
Excel
Device & OS
not provided
Scenario
Reopening an Excel workbook that contains data slicers with multi-select enabled.
Observed behavior
The slicer multi-select button becomes disabled automatically after the workbook is saved and reopened, failing to preserve the user's previous UI state.
Before you start

Ensure that your workbook contains at least one slicer and that you have the Developer tab enabled in your ribbon to insert VBA macros.

Solution 1Recommended

Use a VBA Auto_Open Macro to Enable Multi-Select

Since Excel does not natively preserve the multi-select state of a slicer upon reopening, you can use an Auto_Open macro to automatically select the slicer and trigger the multi-select toggle keyboard shortcut.

This solution utilizes the Auto_Open subroutine, which runs automatically every time the workbook is opened. By simulating the Alt+S keystroke (which triggers the multi-select option on an active slicer), the slicer is set to your preferred state without manual intervention.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the Project Explorer pane on the left, right-click on your workbook name, select 'Insert', and then click 'Module'.

3
Paste the VBA Code

Copy and paste the following code into the blank module window: Sub Auto_Open() ActiveSheet.Shapes.Range(Array("State")).Select SendKeys "%s" End Sub

4
Save as a Macro-Enabled Workbook

Go to File > Save As, and ensure you save the file as an Excel Macro-Enabled Workbook (*.xlsm) so the code runs the next time you open it.

Use a VBA Auto_Open Macro to Enable Multi-Select
Customize Slicer Name: Make sure to replace "State" in the code array with the exact name of your specific slicer shape. You can find the name by clicking the slicer and checking the Name Box next to the formula bar.
Manage Macros and Slicers with WPS Spreadsheet

Easily Handle VBA Macros and Excel Slicers in WPS Office

WPS Spreadsheet provides excellent compatibility with Excel VBA macros and slicers, allowing you to run your Auto_Open scripts seamlessly and manage complex data filtering with ease.

  1. 1. Open the file in WPS Spreadsheet: Launch WPS Office and open your .xlsm workbook.
  2. 2. Enable Macros: If prompted by a security warning at the top of the sheet, click 'Enable Macros' to allow the Auto_Open script to run.
  3. 3. Access Developer Tools: Navigate to the Developer tab to view, edit, or manage your VBA code and macros natively.
Fully compatible with Microsoft Excel .xlsm formats and VBA scripts.Smooth handling of advanced data features like PivotTables and Slicers.Lightweight software with a familiar, easy-to-use interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't Excel save the slicer multi-select state by default?

Excel's native architecture resets the multi-select toggle button on slicers upon reopening a file. The application is designed to save the actual applied data filters, but not the UI state of the slicer button itself.

Can I apply this macro to multiple slicers at once?

Yes. You can expand the VBA code to select multiple slicer shapes sequentially and send the "%s" keystroke for each one, or write a loop to iterate through all slicer objects on the active worksheet.

What does the SendKeys "%s" command do in the macro?

The SendKeys "%s" command simulates pressing the Alt + S shortcut on your keyboard. This is the default hotkey in Excel for toggling the multi-select option on or off when a slicer is actively selected.