VBA & Macro Problems

How to Lock or Unlock All Excel Worksheets with Keyboard Shortcuts

Kushani NimanthikaKushani Nimanthika Nov 11, 2026 868 views

Question details

The user wants to learn how to lock (protect) or unlock (unprotect) all worksheets in an Excel workbook simultaneously by assigning custom keyboard shortcuts to VBA macros.

How to Lock or Unlock All Excel Worksheets with Keyboard Shortcuts
Product
Excel
Device & OS
not provided
Scenario
Securing or editing multiple sheets efficiently without having to protect or unprotect each sheet individually.
Observed behavior
Users need to use VBA macros combined with shortcut assignments, as there is no direct built-in shortcut to protect or unprotect all sheets at once.
Before you start

Ensure you have the VBA macro code ready for protecting and unprotecting sheets, and save your file as a Macro-Enabled Workbook (.xlsm) to preserve the code.

Solution 1Recommended

Assign Keyboard Shortcuts via the Macros Dialog

The simplest way to assign a shortcut key to an existing macro using Excel's built-in Macros options.

1
Open the Macros Dialog

Press Alt+F8 on your keyboard to open the Macros dialog box, which displays all available macros in your workbook.

2
Select the Macro

Click on the name of the macro you created to lock or unlock all worksheets to highlight it.

3
Open Macro Options

Click the 'Options' button on the right side of the dialog box.

4
Assign the Shortcut

In the 'Shortcut key' box, type the letter you want to use (e.g., 'L' for lock or 'U' for unlock). Click 'OK' to save the shortcut, then close the Macros dialog.

Assign Keyboard Shortcuts via the Macros Dialog
Shortcut Key Combinations: By default, this method uses Ctrl + [Letter] or Ctrl + Shift + [Letter]. If you specifically need Alt+L or Alt+U, you must use the VBA Application.OnKey method.
Efficient Spreadsheet Management

Manage Macros and Protect Sheets Easily with WPS Office

WPS Spreadsheet fully supports VBA macros and sheet protection features, allowing you to easily automate tasks and secure your data using custom keyboard shortcuts.

  1. 1. Open Your Workbook: Launch WPS Spreadsheet and open your Macro-Enabled Workbook (.xlsm).
  2. 2. Access Developer Tools: Navigate to the 'Developer' tab on the top ribbon to access all macro and VBA features.
  3. 3. Manage Macros: Click on 'Macros' to open the dialog box where you can run, edit, or assign shortcuts to your sheet protection scripts.
Full compatibility with Microsoft Excel macro formats (.xlsm)Intuitive developer tools for managing VBA codeAdvanced sheet protection to secure sensitive dataLightweight and fast performance for heavy workbooks
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my assigned macro shortcut working?

Ensure that macros are enabled in your Trust Center settings. Also, check if the shortcut combination you chose is overriding a critical system shortcut or is being blocked by another application.

Can I use Ctrl instead of Alt for macro shortcuts?

Yes. When using the Macros Options dialog (Alt+F8 > Options), Excel automatically assigns Ctrl + [Letter] or Ctrl + Shift + [Letter] as the shortcut for your macro.

How do I remove a keyboard shortcut from a macro?

Open the Macros dialog by pressing Alt+F8, select your macro, click 'Options', delete the character from the shortcut key box, and click 'OK'.