Yes, you can call a macro from an Excel hyperlink, and the cleanest official way is the HYPERLINK function pointed back at the workbook itself: place =HYPERLINK("#RunReport()", "Run report") in a cell, where RunReport is a Sub stored in a standard module of that workbook. Clicking the cell runs the macro. The formula trick works because a hyperlink target beginning with # is treated as a location inside the workbook, and Excel resolves a valid macro name there as a call. This is the method Microsoft documents and it has no dependencies on add-ins, shapes or external files. The alternative, a right-click > Link (or Insert > Link) hyperlink with a macro name as the address, does not reliably fire macros in Excel — it was a trick in older versions and now usually opens a file-path error or goes nowhere, so avoid it. The rest of this guide covers setup, the module placement rule that trips up most people, security prompts, and what to check when a click does nothing.

What You'll Need

  • Microsoft Excel on Windows or Mac desktop. Searching, editing and running macros through the HYPERLINK formula needs the desktop app; Excel for the web cannot run VBA.
  • A macro-enabled workbook saved as .xlsm (or .xlsb). Macro-free .xlsx files strip VBA on save.
  • A macro written as a Public Sub with no arguments, in a standard module (Insert > Module in the VBA editor, opened with Alt+F11 on Windows or Option+F11 on Mac).
  • Macro security settings that permit the code — for your own file, the Trust Center macro setting or a Trusted Location.
  • Basic familiarity with the VBA editor, enough to paste code and read the Immediate window.

Step-by-Step

  1. Open the workbook and press Alt+F11 (Windows) or Option+F11 (Mac) to open the Visual Basic editor. You should see the Project Explorer on the left listing your workbook name in bold.
  2. In the Project Explorer, right-click your workbook's name and choose Insert > Module. A blank Module1 appears under the Modules folder. This step matters: code placed in ThisWorkbook or in a sheet module is not reliably reachable from a hyperlink, because those modules are private to their object by default. Only code in a standard module can be called by name this way.
  3. In the module's code window, type your macro. A minimal, safe starting point is:
    Public Sub RunReport()
        MsgBox "Macro ran at " & Now
    End Sub
    The keyword Public is optional in a standard module but makes the intent explicit. Do not add parameters — a hyperlink call cannot pass arguments.
  4. Press F5 while the cursor is inside the procedure to confirm the macro runs standalone. If a message box appears, the code is fine and the problem, if any, will be in the link rather than the macro.
  5. Save the file in .xlsm format: File > Save As, then choose Excel Macro-Enabled Workbook. If you skip this, closing and reopening the file removes the macro and the hyperlink will appear dead.
  6. Return to the worksheet and click the cell where you want the clickable link. Type the formula, quoting both parts: =HYPERLINK("#RunReport()", "Run report"). Excel displays the friendly text and underlines it with the usual link styling when you hover or click.
  7. Click the cell. If macros are enabled for the file, the macro runs. If a yellow security bar is visible at the top of the window saying macros have been disabled, click the button on the bar to enable them once, or move the file into a folder you have added as a Trusted Location under File > Options > Trust Center > Trust Center Settings > Trusted Locations. The exact label wording can differ slightly between Excel versions, and the Trust Center path is found under the Excel menu on Mac rather than the File menu.
  8. Test from a fresh session: close the workbook completely, reopen it, and click the link again. This confirms the code survived the save and that the prompt you see on open is the normal macro-enable prompt rather than an error.
  9. Style the cell if you like: bold it, apply a fill colour, or widen the column so the friendly text is not truncated. The formula's display text, not the cell formatting, is what gets clicked, so keep the cell height generous enough that the whole address bar is visible.
  10. For more than one action, add a separate Public Sub per action in the same module and give each link its own name, for example =HYPERLINK("#RefreshData()", "Refresh"). Keep names unique across the workbook; duplicate procedure names in standard modules cause a compile error and every link then fails.

Common Mistakes

The single biggest cause of a dead link is putting the macro in the wrong module. If your code sits in the worksheet's own module — visible in the Project Explorer as Sheet1 (Sheet1) — a hyperlink call by bare name cannot reach it. Move the procedure to a standard module (or copy it there and call the sheet-level routine from a wrapper).

The second common mistake is omitting the parentheses. =HYPERLINK("#RunReport", "Run report") without () often produces a reference error or navigates to a blank location instead of invoking the procedure. Always write RunReport(), exactly as you would in a Call statement.

Third, saving as .xlsx silently discards all VBA. Excel warns you, and many people click through the warning. The file opens looking identical, but every macro link is dead and the VBA editor is empty. Re-save as .xlsm and re-add the code.

Fourth, macros that take arguments cannot be linked. Sub DoThing(ByVal n As Long) has no way to receive n from a hyperlink. Wrap it: create Public Sub DoThingLink() with no arguments that calls DoThing 5 internally, and point the link at the wrapper. Fifth, naming the macro with spaces or punctuation, such as Sub Run Report, breaks the call; use letters, digits and underscores only.

Tips

Prefix the display text with a verb so readers know the cell is an action, not a reference — "Run report", "Email this sheet", "Reset filters". A bare file name or a vague label invites accidental clicks. Keep the macro short and give it a single job; a link that fires a long chain of sheets, emails and saves is hard to test and harder to undo, and users who misclick have no confirmation step.

Consider adding a one-line confirmation in the macro, such as a message box asking "Run the report now?" with Yes and No, before anything destructive happens. A confirmation prompt costs one click and prevents the most common support question: "I clicked it and something changed — how do I get it back?".

If you distribute the workbook, tell recipients they will see the macro-enable bar on open and explain that they should enable macros only if they trust the sender. Never instruct people to lower macro security to the lowest setting across the board — a Trusted Location for a specific folder is the appropriate permission.

To label the destination more clearly, use a shape instead of a cell and assign the macro folder: right-click the shape, choose Assign Macro, and pick the procedure. That is a separate mechanism from the hyperlink formula and behaves differently — it fires without the # syntax — but a shape cannot show the familiar link cursor, so many users prefer the formula for discoverability.

Troubleshooting

If clicking the link does nothing, first check the security bar. A disabled-macro state is the most frequent cause and the link will appear live but inert. Enable macros for this session, or add the containing folder to Trusted Locations and reopen.

If you get an error about a reference or the cell jumps elsewhere, inspect the formula for the # prefix and the trailing parentheses, and confirm the name matches the procedure exactly, including capitalisation-sensitive spelling. Use the Immediate window (Ctrl+G in the VBA editor) and type Application.Run "RunReport" to test whether the procedure is reachable at all — if that fails, the module placement or the name is wrong.

If the macro ran fine yesterday and not today, check whether the file was saved as .xlsx, was opened from a network location that Excel treats as untrusted, or was opened in Protected View (the yellow bar at the top of the window). Close Protected View by clicking Enable Editing, then enable content. If the workbook was downloaded from the internet, Windows may have marked it; right-click the file in File Explorer, open Properties, and clear the unblock checkbox if it is present, then reopen.

If the link fires twice, look for duplicate event code or a copy of the procedure in two modules. Rename one, or delete the duplicate, and re-test. If the click opens a blank page or a "Cannot open the specified file" message, confirm you did not use Insert > Link with the macro name in the Address box — replace it with the HYPERLINK formula.

Frequently Asked Questions

Can a hyperlink pass a value to the macro?

Not directly. A hyperlink call cannot supply arguments. Create a wrapper procedure with no parameters that calls your real macro with the value hard-coded inside it, and point the link at the wrapper.

Does this work in Excel for the web or on a phone?

No. Excel for the web and the mobile apps do not run VBA macros. The workbook must be opened in the desktop app on Windows or Mac for the link to invoke code.

Will the link still work if I move the workbook to another folder?

Yes. The # target is internal to the workbook, so the file can be moved or renamed without breaking the call, as long as macros are enabled when it is opened.

Why does my link work for me but not for colleagues?

Almost always macro security. Their copy is opened with macros disabled, or the file arrived from an untrusted source. Ask them to use the enable button on the security bar or add the file's folder as a Trusted Location.

Can I use a button instead of a cell link?

Yes. Insert a shape or button, right-click it, choose Assign Macro, and select the procedure. This is a different mechanism from the HYPERLINK formula but achieves the same result with a more button-like appearance.

Can I run a macro in another workbook from a link?

The formula calls procedures in the workbook containing it. To reach another file, write a wrapper in the current workbook that opens the other file (or uses a reference to it) and calls the procedure there; the link itself still points at the local wrapper.