Skip to content

Make an Excel Macro Available in Every Workbook

  • by
Make excel available for all workbooks

Quick answer: To run your own VBA macros in any workbook in desktop Excel, save them in the hidden Personal Macro Workbook (PERSONAL.XLSB). To install reusable functions or procedures as a separate component, create and enable an Excel add-in (.xlam). Neither option makes VBA run in Excel for the web.

By default, a macro stored in an ordinary .xlsm workbook is available while that workbook is open. For repeated use across desktop Excel workbooks, choose a personal macro workbook (PERSONAL.XLSB) or an installed Excel add-in (.xlam). These are different approaches: PERSONAL.XLSB is convenient for your own macros; an add-in is useful for distributing reusable procedures and functions.

Method 1: Install a reusable Excel add-in (.xlam)

  1. In desktop Excel for Windows, open the workbook containing the VBA code. Press Alt+F11 to open the Visual Basic Editor; use Insert > Module to add a standard module if needed.
  2. Place a reusable Public Sub or Public Function in the module. Test it in a copy of your workbook before distributing it.
  3. Choose File > Save As, then select Excel Add-In (*.xlam) as the file type. Save it to a location you can access later. Saving alone does not activate the add-in.
  4. Go to File > Options > Add-ins. At the bottom, choose Excel Add-ins in the Manage box and select Go.
  5. Select the add-in if it is listed, or choose Browse to locate the .xlam file. Check its box to enable it. Restart Excel if necessary.
  6. Open another workbook and confirm that the macro or function is available. An add-in macro may not appear in the standard Macros dialog; you can call a public procedure from VBA or assign it to a button or shortcut as appropriate.
Activating excel macro/add-ins to make macro available for each workbook
Activate excel macro/add-ins to make macro available for each workbook

Method 2: Use PERSONAL.XLSB for your own macros

  1. In desktop Excel, go to View > Macros > Record Macro (or Developer > Record Macro).
  2. Under Store macro in, select Personal Macro Workbook, record a harmless action, and stop recording.
  3. Press Alt+F11 to edit the recorded procedure in PERSONAL.XLSB or add your own standard module.
  4. Close Excel and accept the prompt to save changes to the Personal Macro Workbook. It normally opens hidden automatically when desktop Excel starts.

If PERSONAL.XLSB already exists, do not create another one; open the Visual Basic Editor and locate it in the Project Explorer. Keep a backup before changing it. PERSONAL.XLSB is stored in Excel’s startup location, which can vary by installation and operating system.

Using a personal macro workbook or add-in on Mac

Desktop Excel for Mac also supports VBA, but its ribbon and add-in dialogs differ from Windows. Use Tools > Macro > Record New Macro (or the Developer tab, if enabled), select the Personal Macro Workbook when offered, then save it when quitting Excel. For add-ins, use Tools > Excel Add-ins where available, select Browse to locate the .xlam file, and enable it. Check your Excel version’s menus because Microsoft changes these controls over time. Windows-only ActiveX controls and operating-system-specific VBA calls are not portable to Mac.

Checklist before sharing a VBA add-in

  • Save a backup of the original .xlsm and .xlam files, and record the Excel versions used for testing.
  • Test the public procedures and worksheet functions in a new workbook, including blank, text and error inputs.
  • Confirm that no code uses hard-coded local file paths, credentials, or platform-specific libraries without documented alternatives.
  • Explain installation, removal, macro trust, and update procedures to recipients; do not ask them to disable organization-wide security protections.
  • When a workbook depends on a custom worksheet function, document the required add-in and provide a fallback value or exported results for readers who cannot install it.

Example: A reusable VBA function

Put the following function in a standard module of your add-in. After enabling the add-in, enter =CelsiusToFahrenheit(A2) in a worksheet cell containing a Celsius temperature in A2. A worksheet function must return a value; it cannot directly change other cells.

Public Function CelsiusToFahrenheit(ByVal Celsius As Double) As Double
    CelsiusToFahrenheit = Celsius * 9# / 5# + 32#
End Function

For example, an input of 0 returns 32, and an input of 100 returns 212. This simple function expects numeric inputs; passing text or an error cell can cause a worksheet error. If Excel does not recognize the function, check whether the add-in is enabled, macros are permitted, and the function is in a standard module. If you put the function in PERSONAL.XLSB instead, a worksheet formula may need a workbook-qualified function reference; an installed add-in is generally more convenient for worksheet functions.

Verification: Test the Function in a Separate Workbook

After enabling the add-in, create a new blank workbook and enter 0 in A2, 100 in A3, and −40 in A4. In B2 enter =CelsiusToFahrenheit(A2) and fill the formula down through B4. The expected values are 32, 212, and −40. Close and reopen Excel, then repeat the test to confirm that the add-in loads on startup. This is a suggested reproducible check, not a claim that the code was tested in every Excel version.

For a personal macro stored in PERSONAL.XLSB, confirm that the workbook loads hidden and the macro is available after restarting Excel. If a worksheet function returns #NAME?, inspect the add-in’s enabled state and the exact function name before changing security settings. For an untrusted downloaded add-in, obtain a trusted copy from its publisher or your IT administrator; never instruct readers to disable macro protections globally.

Accessibility: Include descriptive column headers such as Celsius and Fahrenheit in examples, and explain any custom function in nearby text. A recipient who cannot run VBA should still be able to understand the results. Related: how to enable the Excel fill handle for copying the test formula down a column.

Troubleshooting and security

  • The add-in does not appear: choose Browse in the Excel Add-ins dialog and select the saved .xlam file. An add-in is not enabled merely by saving it.
  • Macros are blocked: organizational policies, Trust Center settings, or Windows’ downloaded-file protections may prevent execution. Do not bypass security controls or enable untrusted code.
  • A procedure is missing from the Macros dialog: functions and procedures with arguments are generally not listed there. Use a suitable VBA call, worksheet formula for a public UDF, or an assigned button.
  • Excel for the web: it cannot run VBA macros; use desktop Excel for VBA-based workflows.
  • Sharing: recipients must install and trust the add-in themselves; a worksheet that calls its custom function may show #NAME? when the add-in is unavailable. Store the original source in a backed-up, version-controlled location, and avoid distributing macros that users have not reviewed.

Frequently asked questions

Should I use PERSONAL.XLSB or an .xlam add-in? Use PERSONAL.XLSB for personal shortcuts and procedures on one computer. Use an add-in for a maintained collection of reusable functions or macros that you intend to install on multiple computers.

Will these macros work in Excel online? No. Excel for the web does not execute VBA, although you can open and edit a workbook containing VBA without running the macros.

Where can I verify the setup? See Microsoft’s Personal Macro Workbook guidance and Excel add-in management instructions. Menu wording may vary by platform and version.

Leave a Reply

Your email address will not be published. Required fields are marked *