Excel VBA Hyperlink to Worksheet: A Practical Guide

VBA & macros · Updated November 21, 2026

To make a cell link to another worksheet with VBA, use Hyperlinks.Add and set Address to an empty string and SubAddress to the destination sheet and cell. For example, a link from Contents!B2 to Sales Data!A1 uses SubAddress:="'Sales Data'!A1"; a complete macro is shown below.

How an Excel worksheet hyperlink works

A link within the same workbook is an internal hyperlink. It points to a location in the workbook rather than to a web page or a separate file. In VBA, the Hyperlinks.Add method creates it: Anchor is the cell or object that displays the link, Address is the external destination, and SubAddress identifies the location inside a workbook. For an internal link, leave Address empty and supply the destination in SubAddress.

The subaddress normally consists of the worksheet name, an exclamation mark, and a cell reference. A simple sheet name might be written as Summary!A1. If a sheet name contains spaces or punctuation, enclose it in single quotation marks, as in 'Sales Data'!A1. The quotation marks are part of the reference, not decorative text. Excel uses the destination cell to decide where to position the view after the reader follows the link.

This creates a normal clickable hyperlink, not a command that runs a macro when clicked. That distinction matters: a workbook hyperlink can take a reader to a sheet without enabling VBA, while a button assigned to a macro requires macros to be enabled. For a table of contents, navigation panel, or “back to summary” link, an internal hyperlink is often the simpler and safer choice.

Create a link with VBA

The following example places a link in cell B2 of a worksheet named Contents. It sends the reader to A1 on Sales Data in the same workbook. Change the two sheet names, source cell, destination cell, and display text to suit your file.

Option Explicit

Sub AddWorksheetLink()
    Dim wb As Workbook
    Dim sourceCell As Range
    Dim targetSheet As Worksheet
    Dim subAddress As String

    ' Use the workbook that contains this VBA code.
    Set wb = ThisWorkbook
    Set targetSheet = wb.Worksheets("Sales Data")
    Set sourceCell = wb.Worksheets("Contents").Range("B2")

    ' Quote the sheet name and double any apostrophe in its name.
    subAddress = "'" & Replace(targetSheet.Name, "'", "''") & "'!A1"

    ' Replace any existing hyperlink in the source cell.
    sourceCell.Hyperlinks.Delete
    sourceCell.Hyperlinks.Add Anchor:=sourceCell, Address:="", _
        SubAddress:=subAddress, TextToDisplay:="Go to Sales Data"
End Sub

The macro uses ThisWorkbook, which means the workbook containing the code. That is usually appropriate when the code is stored in the workbook being edited. If the macro is stored in Personal.xlsb or an add-in, ThisWorkbook refers to that container instead; in that situation, deliberately identify the intended workbook rather than assuming the active workbook is the right one. Using ActiveWorkbook can work, but the active workbook may change while the macro is running.

To run the example in Excel for Microsoft 365 on Windows, save a working copy as an Excel Macro-Enabled Workbook (*.xlsm), open the VBA editor with Alt+F11, insert a standard module using Insert > Module, paste the code, and run AddWorksheetLink. You can also open the editor from Developer > Visual Basic. On a Mac, use Tools > Macro > Visual Basic Editor or the Developer tab; the keyboard shortcut can depend on the keyboard and function-key settings. Excel for the web can open a workbook containing VBA and follow its hyperlinks, but it cannot create or run VBA macros.

Choose the right source and destination

A hyperlink needs a deliberate anchor and target. The anchor is where the clickable text appears; the target is where Excel navigates. Keep them conceptually separate, especially when generating many links. For instance, a contents sheet might have department names in column A and one link in column B for each corresponding worksheet. The link cell can display a friendly label rather than exposing the sheet name or cell address.

  • Choose a clear anchor. Use a single cell such as B2 for a simple link. A shape or other object can also act as an anchor, but the example uses a cell because it is easy to locate and maintain.
  • Choose a useful destination. A1 is a common landing point, but a sheet may have a title or instructions farther down. Point to the first meaningful cell, such as A5, when that gives readers a better starting view.
  • Use the exact worksheet name. A misspelled name or a name that differs by an extra space will not identify the intended sheet. Worksheet names are not case-sensitive for ordinary Excel references, but accurate spelling avoids ambiguity.
  • Decide what the link should say. Text such as “Open quarterly results” explains the action better than “Click here.” The link text does not have to match the destination sheet name.

If a destination cell is likely to move as the workbook changes, consider whether a defined name would be more stable than a fixed address. A named range can provide a meaningful destination, but it must exist in the workbook and the subaddress must refer to it correctly. For fixed landing cells in a worksheet, a direct cell reference is usually clearer and easier to troubleshoot.

Handle sheet names and workbook references safely

Sheet names with spaces must be quoted in a reference. Names can also contain apostrophes, so the example applies Replace to double an apostrophe before surrounding the name with single quotes. This follows Excel’s worksheet-reference notation and helps avoid malformed references for unusual, but valid, sheet names. If you know all worksheet names are simple, unquoted references may appear to work, but quoting consistently is a robust habit.

The example assumes both worksheets already exist in the same workbook. If either name is missing, the line that assigns the worksheet object raises a VBA error before it can create a link. When a macro will run on files with varying sheet layouts, check that the required worksheets exist first and show a clear message if one is absent. Do not silently create a link to a guessed or similarly named sheet; a misleading navigation link is harder for a reader to diagnose than a clear error.

For links to another workbook, the design changes: the destination file belongs in Address, and the location within that file can be specified through SubAddress. Such links can break if the file is renamed, moved, or unavailable. The code above intentionally creates an internal link only; it does not build an external file path.

Make links for several worksheets

For a workbook with many tabs, a contents sheet can be populated from a list of worksheet names. A loop can read each listed name, find the corresponding worksheet, and add a link beside it. The important design decision is what should happen when a name in the list does not match a real worksheet. A production macro should skip it with a warning or report it clearly, rather than stopping halfway through without explaining which entries were processed.

When creating a batch of links, keep the source cells distinct and avoid overwriting useful content. Decide whether the macro should replace links each time it runs, as the example does for its one source cell, or preserve existing links. If you clear a whole output range before rebuilding a contents page, limit the clearing operation to that intended range; broad clearing can erase labels, formulas, or formatting that the macro does not own. Testing on a copy is especially important for batch changes.

For dynamic workbooks, decide whether the list of links should include hidden worksheets. A macro that loops through every worksheet may include hidden tabs unless it checks each sheet’s visibility. Also consider whether the workbook contains chart sheets: a collection intended for worksheets should be handled as worksheets, not assumed to contain only visible tabs. Explicitly defining the desired behavior prevents a navigation page from exposing destinations that were meant to remain out of view.

Common problems and fixes

  • The link opens a web browser or another file. Check that Address is an empty string for an internal link and that the sheet and cell are in SubAddress. A file path in Address makes the hyperlink external.
  • Excel reports a subscript error. The worksheet name supplied to Worksheets may not exist in the workbook referenced by wb. Check spelling, spaces, and which workbook the macro is using.
  • The link points to the wrong cell. Inspect the last part of subAddress, such as !A1. Change it to the intended address, and remember that a fixed cell reference does not automatically mean “the top of the data” if the layout changes.
  • The text is not what you expected. TextToDisplay controls the text shown in the anchor cell. If the cell already had content or a hyperlink, confirm that the macro targets the intended cell and that replacement is acceptable.
  • It looks like a link but does not navigate on a click. Excel desktop may require Ctrl+click to follow hyperlinks, depending on the setting. On Windows, check File > Options > Advanced > Editing options for “Use Ctrl+Click to follow hyperlink.” The setting and interaction can vary by platform.

Internal links do not have to include a leading number sign when passed as the SubAddress argument to Hyperlinks.Add. A leading # is commonly seen in worksheet hyperlink formulas or other hyperlink contexts, which can cause confusion when copying examples between methods. For the VBA method above, use the sheet-and-cell reference as shown, without adding a hash mark.

Hyperlink or a navigation macro?

Use a hyperlink when the goal is simply to move the reader to a location. It is easy to create, can be followed without running VBA, and remains an ordinary workbook link. Use a macro assigned to a shape or button when clicking must perform additional actions, such as filtering a report, preparing a print view, or navigating based on user input. That approach offers more control but introduces macro security prompts and requires a macro-enabled workbook.

A third option is Excel’s built-in link interface, which is useful for a small number of links or for workbooks where macros are not permitted. On Windows, select the source cell and use Insert > Link, then choose a place in this document and select the destination. The interface is slower for dozens of links, but the resulting internal link has the same basic purpose. On a Mac, use Insert > Link and choose the in-workbook destination option available in that Excel version.

Excel for the web supports following workbook links, but VBA is not available to run there. If recipients commonly use Excel in a browser, create the links in desktop Excel before sharing, or use the built-in link interface rather than relying on a macro that recipients must run. Keep the workbook’s intended usage in mind: a desktop automation solution is not automatically suitable for a browser-based workflow.

Save, security, and undo considerations

Save the workbook as .xlsm if it needs to retain VBA. Saving as a standard .xlsx file does not preserve VBA macros; Excel warns about removing them when saving in that format. A hyperlink created by a macro is workbook content, but the macro itself must remain available if users need to regenerate or update the links later.

Only enable macros in files from sources you trust. A macro that adds a link is modest in scope, but VBA can perform broader actions, so do not treat a harmless-looking link as proof that a workbook’s code is safe. Before running a macro that edits a workbook, save a separate copy. Macro actions cannot be reversed with Ctrl+Z, so a backup is the practical way to recover from an unintended change. On Mac, the equivalent undo shortcut is Command+Z, but it does not undo VBA changes either.

Frequently Asked Questions

Can VBA link to a specific cell on another worksheet?
Yes. Set the hyperlink’s SubAddress to the destination sheet and cell, such as 'Sales Data'!D12, and leave Address empty for a link within the same workbook.

Do I need to put a # before the sheet name?
Not for the SubAddress argument in the Hyperlinks.Add example here. Use a worksheet reference such as 'Sales Data'!A1. Other hyperlink methods may display or require a leading number sign, so do not mix their syntax without checking the method.

Can I link to a worksheet with spaces in its name?
Yes. Enclose the sheet name in single quotation marks in the subaddress, for example 'Quarterly Results'!A1. The sample macro builds this format automatically and doubles apostrophes inside a sheet name.

Will the link work in Excel for the web?
A created internal hyperlink can be followed in Excel for the web. However, Excel for the web does not run VBA, so use desktop Excel to run the macro or create the link through the browser’s available link tools.

Why does the macro say a worksheet does not exist?
Check the spelling of the name and confirm that the worksheet is in the workbook referenced by the macro. In particular, ThisWorkbook means the workbook containing the code, not necessarily the workbook currently selected on screen.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.