logo
search
VBA & Macro Problems

How to Fix Excel VBA 'This Won't Work on Multiple Selections' Error

Maira MehtabMaira Mehtab Sep 21, 2026 873 views

Question details

The user encounters an intermittent VBA macro error stating 'This won't work on multiple selections' when attempting to add a new worksheet.

Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro that retrieves data from an external file and creates temporary worksheets for calculations in a workbook with password-protected sheets.
Observed behavior
The macro randomly fails to add a worksheet and throws the multiple selections error, even though no multiple worksheets appear to be manually selected by the user.
Before you start

Before editing your VBA code, check the top title bar of your application to ensure your worksheets are not accidentally grouped (indicated by the word '[Group]' next to the file name), as this restricts structural changes.

Solution 1Recommended

Ungroup Visible and Hidden Worksheets

This error most commonly occurs when multiple worksheets are grouped together, which prevents Excel from adding new sheets via macros.

Even if you only see one active worksheet, hidden sheets might be grouped or selected in the background due to previous macro actions. Ungrouping them will resolve the restriction.

1
Check for Grouped Sheets

Look at the sheet tabs at the bottom. If multiple tabs are highlighted in a lighter color, they are grouped.

2
Ungroup Sheets

Right-click on any active sheet tab at the bottom of the window and select 'Ungroup Sheets' from the context menu.

3
Unhide Worksheets

Right-click a sheet tab, click 'Unhide', and ensure no hidden sheets are inadvertently remaining in a grouped state.

4
Modify VBA Code

Add 'ActiveSheet.Select' before the worksheet addition command in your VBA code to ensure only a single worksheet is actively selected when the macro runs.

Code Best Practice: Avoid using '.Select' and '.Activate' in your VBA code whenever possible. Direct referencing (e.g., Worksheets.Add) often prevents selection-based errors entirely.
Advanced Spreadsheet Editor

Run Macros and Manage Worksheets Smoothly with WPS Spreadsheet

WPS Office provides highly reliable compatibility with Excel macros (VBA). You can safely execute complex data-fetching scripts, auto-generate calculation worksheets, and manage document protection seamlessly.

  1. 1. Open Your Macro File: Launch WPS Spreadsheet and open your existing .xlsm or .xls workbook.
  2. 2. Access Developer Tools: Navigate to the 'Developer' tab on the main ribbon to access your VBA environment.
  3. 3. Run the Script: Click on 'Macros', select the script that generates your temporary worksheets, and click 'Run'.
  4. 4. Manage Sheet Protection: Go to the 'Review' tab to quickly unprotect workbooks or ungroup sheets before executing complex structural macros.
Excellent compatibility with Microsoft Excel (.xlsx, .xlsm, .xls) macro formats.Robust VBA support for automating tasks without unexpected selection errors.Lightweight architecture handles complex external data fetching effortlessly.Intuitive UI to easily manage grouped tabs and sheet protection.
QA img-10

Frequently Asked Questions

Why does the 'This won't work on multiple selections' error happen intermittently?

Intermittent errors often occur because a previous action in the macro, or a user's manual action beforehand, left multiple worksheets grouped. If the macro doesn't explicitly ungroup or select a single sheet before adding a new one, the error triggers unpredictably based on the previous state.

How do I know if my worksheets are grouped in Excel?

You can tell worksheets are grouped if multiple sheet tabs at the bottom of the window have a solid white or highlighted background. Additionally, the word '[Group]' will appear in the application title bar at the very top of the window next to the file name.

Can workbook protection cause worksheet addition errors in VBA?

Yes. If the workbook structure is protected, macros are blocked from adding, deleting, or moving worksheets. You must unprotect the workbook—either manually via the Review tab or programmatically within the VBA script—before executing the worksheet addition command.

Does WPS Office support Excel VBA macros?

Yes, WPS Office offers excellent support for VBA macros. By enabling the Developer tools in WPS Spreadsheet, you can write, edit, and run macro scripts seamlessly with high compatibility for standard Excel macro files (.xlsm).