VBA & Macro Problems

How to Create Cross-Platform Excel Macro Keyboard Shortcuts for Mac and Windows

Adam DavisAdam Davis Oct 26, 2026 870 views

Question details

The user needs to set up reliable keyboard shortcuts for Excel macros that function consistently across both Mac and Windows operating systems.

How to Create Cross-Platform Excel Macro Keyboard Shortcuts for Mac and Windows
Product
Microsoft Excel
Device & OS
Mac and Windows
Scenario
Assigning and using keyboard shortcuts for shared VBA macro workbooks across different operating systems.
Observed behavior
Keyboard shortcuts assigned on one operating system (such as Shift+Control+C on Mac) fail to trigger the macro consistently when the workbook is opened on the other operating system.
Before you start

Ensure you have the Developer tab enabled in your ribbon and have saved a backup of your macro-enabled workbook (.xlsm) before modifying the VBA code.

Solution 1Recommended

Use Application.OnKey with Conditional OS Compilation

The most reliable programming method to handle platform differences is detecting the operating system via VBA and assigning the appropriate shortcut key dynamically.

Because Mac and Windows handle keyboard modifiers (like Control and Command) differently, standard shortcut assignments often break. By using VBA compiler constants, you can execute different Application.OnKey commands depending on the user's operating system.

1
Open the VBA Editor

Press Alt + F11 on Windows (or Option + F11 on Mac) to open the Visual Basic for Applications (VBA) editor.

2
Insert OS Detection Code

In the 'ThisWorkbook' module, use the Workbook_Open event to check the OS. Write `#If Mac Then` to specify the Mac Application.OnKey string, and `#Else` to specify the Windows string (e.g., using '^' for Control).

3
Define the Key Bindings

For Windows, code `Application.OnKey "^+C", "YourMacroName"`. For Mac, adapt the modifier string to target the Mac-specific Command or Control key as needed.

4
Save and Test

Save the workbook as a Macro-Enabled Workbook (.xlsm). Open the file on both a Mac and a Windows machine to verify the shortcut works properly.

Use Application.OnKey with Conditional OS Compilation
Resetting Shortcuts: Remember to reset the key binding upon closing the workbook using the Workbook_BeforeClose event by calling Application.OnKey with the key sequence but omitting the macro name.
Free Microsoft Office alternative

Try WPS Office for Seamless Macro and Spreadsheet Management

Struggling with cross-platform Excel quirks? WPS Office provides a robust, highly compatible alternative to Microsoft Office. It supports advanced spreadsheet functions and VBA macros, allowing you to seamlessly process .xlsm files with zero formatting loss.

  1. 1. Download the Software: Visit the official WPS website and download the free WPS Office suite.
  2. 2. Install WPS Office: Run the installer and follow the quick, lightweight installation process.
  3. 3. Open Your Macro Workbook: Launch WPS Spreadsheet and open your .xlsm file to continue running your macros effortlessly.
Fully compatible with Microsoft Excel formats (.xlsx, .xlsm, .csv).Robust support for VBA macros, Form Controls, and complex formulas.Free, lightweight, and fast-loading spreadsheet application.Familiar user interface requiring zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why do my Excel macro shortcuts work on Mac but not Windows?

Mac and Windows use different underlying keyboard modifier structures (Command vs. Control). An identical shortcut assigned via the macro options menu in one operating system often fails to map correctly to the equivalent keys in the other.

What is the Application.OnKey method in VBA?

Application.OnKey is a VBA function that instructs Excel to run a specific macro whenever a designated key or combination of keys is pressed. It is highly useful for programmatically controlling shortcuts rather than relying on Excel's UI.

Can I use the Quick Access Toolbar for cross-platform macros?

Yes. Assigning a macro to a custom Ribbon tab or the Quick Access Toolbar (QAT) bypasses keyboard mappings completely. Clicking a custom UI button is a reliable cross-platform solution for running macros on both Mac and Windows.