VBA Hyperlink to Range: How to Add Links in Excel

VBA & macros · Updated November 23, 2026

To add a hyperlink to a range in Excel VBA, use the Hyperlinks.Add method with the range object as the first argument, for example: Range("A1").Hyperlinks.Add Anchor:=Range("A1"), Address:="https://example.com". This creates a clickable link in the specified cell, and you can also link to other sheets, workbooks, or email addresses.

Understanding the Hyperlinks.Add Method

The Hyperlinks.Add method is the core way to insert hyperlinks programmatically. Its syntax is:

Hyperlinks.Add Anchor, Address, [SubAddress], [ScreenTip], [TextToDisplay]
  • Anchor – The range or shape where the hyperlink is added (required).
  • Address – The URL or file path (required for external links).
  • SubAddress – A location within the same workbook, like a sheet name or named range (optional).
  • ScreenTip – The tooltip text shown on hover (optional).
  • TextToDisplay – The visible text in the cell (optional; defaults to the Address).

For example, to add a link to a cell that displays “Click Here” and points to a website:

Sub AddExternalLink()
    Dim rng As Range
    Set rng = ThisWorkbook.Sheets("Sheet1").Range("A1")
    rng.Hyperlinks.Add Anchor:=rng, Address:="https://www.example.com", _
        ScreenTip:="Visit Example", TextToDisplay:="Click Here"
End Sub

Remember to save a copy of your workbook before running any macro, as macros cannot be undone with Ctrl+Z.

Linking to a Cell in the Same Workbook

To create an internal hyperlink that jumps to another sheet or a named range, use the SubAddress parameter. The syntax for the sub-address is "SheetName!CellReference" or "SheetName!NamedRange".

Sub AddInternalLink()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1")
    ' Link to cell B5 on Sheet2
    ws.Range("C1").Hyperlinks.Add Anchor:=ws.Range("C1"), _
        Address:="", SubAddress:="Sheet2!B5", TextToDisplay:="Go to Sheet2"
End Sub

If the sheet name contains spaces, enclose it in single quotes: "'My Sheet'!B5". This works in all Excel versions that support VBA.

Using a Loop to Add Hyperlinks to Multiple Cells

Often you need to add hyperlinks to a whole column or range. A simple loop can do this efficiently. For example, to add a link to each cell in column A based on a URL in column B:

Sub AddLinksToRange()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long
    Set ws = ThisWorkbook.Sheets("Sheet1")
    lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
    For i = 1 To lastRow
        ws.Cells(i, 1).Hyperlinks.Add Anchor:=ws.Cells(i, 1), _
            Address:=ws.Cells(i, 2).Value, TextToDisplay:=ws.Cells(i, 2).Value
    Next i
End Sub

This assumes column B contains full URLs (e.g., https://example.com). The loop runs from row 1 to the last non-empty cell in column B. For very large ranges (thousands of rows), consider disabling screen updating with Application.ScreenUpdating = False at the start and re-enabling it at the end to speed up the process.

Removing or Modifying Existing Hyperlinks

To remove a hyperlink from a range, use the Hyperlinks.Delete method on the range’s hyperlink object. For example:

Sub RemoveLink()
    Dim rng As Range
    Set rng = ThisWorkbook.Sheets("Sheet1").Range("A1")
    If rng.Hyperlinks.Count > 0 Then
        rng.Hyperlinks.Delete
    End If
End Sub

To change the address of an existing hyperlink, you can modify the Address property of the Hyperlink object:

Sub ChangeLink()
    Dim hl As Hyperlink
    Set hl = ThisWorkbook.Sheets("Sheet1").Range("A1").Hyperlinks(1)
    hl.Address = "https://newexample.com"
    hl.TextToDisplay = "New Link"
End Sub

Note that Hyperlinks(1) refers to the first hyperlink in that cell; a cell can only have one hyperlink, but a shape can have multiple.

Common Mistakes and How to Avoid Them

  • Forgetting the Address for internal links – When linking within the workbook, set Address:="" (empty string) and provide only the SubAddress. If you omit the Address entirely, VBA may throw an error.
  • Using the wrong sheet reference – Always qualify the range with the worksheet object, e.g., ThisWorkbook.Sheets("Sheet1").Range("A1"). Using Range("A1") alone refers to the active sheet, which can cause errors if the wrong sheet is active.
  • Not handling spaces in sheet names – For sheet names with spaces, wrap the sheet name in single quotes in the SubAddress, like "'My Data'!A1".
  • Assuming the hyperlink is automatically styled – Excel applies blue underlined formatting by default, but if you change the cell’s font or color after adding the link, it may not look like a link. You can manually set the font color and underline using VBA if needed.

Alternative: Using the FollowHyperlink Method

If you want to open a hyperlink from VBA without adding it to a cell, use the FollowHyperlink method of the Workbook object. For example:

Sub OpenLink()
    ThisWorkbook.FollowHyperlink Address:="https://www.example.com", NewWindow:=True
End Sub

This opens the URL in the default browser. It does not create a hyperlink in any cell. This is useful for automating actions based on cell values without permanently adding links.

Frequently Asked Questions

How do I add a hyperlink to a range of cells at once?

You cannot add a single hyperlink to a multi-cell range; each cell must have its own hyperlink. Use a loop (as shown above) to iterate through each cell in the range and add a hyperlink individually. Alternatively, you can add a hyperlink to a shape that covers multiple cells, but that is a different object.

Can I link to a named range in VBA?

Yes, use the SubAddress parameter with the named range’s name, e.g., SubAddress:="MyNamedRange". The named range must exist in the workbook. This works for ranges defined on any sheet.

Why does my hyperlink show the full URL instead of friendly text?

If you don’t specify TextToDisplay, Excel uses the Address as the visible text. Set TextToDisplay to a friendly label like “Click here” to change what the user sees.

How do I add a hyperlink to an email address?

Use Address:="mailto:someone@example.com". You can also add a subject line by appending ?subject=Subject%20Here (use %20 for spaces). For example: mailto:test@example.com?subject=Hello.

Does this work in Excel for Mac?

Yes, the Hyperlinks.Add method works in Excel for Mac. The VBA syntax is identical, though some keyboard shortcuts differ. The code examples above will run on both Windows and Mac without modification.

Can I remove all hyperlinks from a worksheet with VBA?

Yes, loop through all cells in the used range and delete each hyperlink. A simpler approach is to use Cells.Hyperlinks.Delete after selecting the entire worksheet, but this may be slow on large sheets. A faster method is to use ActiveSheet.Cells.Hyperlinks.Delete, but be careful—this removes all hyperlinks from the active sheet.

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.