Name

hyperlinks.Add(Anchor, Address, [SubAddress], [ScreenTip], [TextToDisplay])

Synopsis

Adds a hyperlink.

Argument

Settings

Anchor

A Range or Shape object to set as the location of the hyperlink.

Address

The URL to navigate to when the hyperlink is clicked.

SubAddress

A location on the page. SubAddress is appended to Address and preceded by #.

ScreenTip

A tool tip to display when the mouse pointer pauses over the hyperlink.

TextToDisplay

The text to show on screen in place of the hyperlink.

For example, the following code adds a hyperlink to range A1:

Sub AddHyperlink(  )
    Dim ws As Worksheet
    Set ws = ActiveSheet
    ws.Hyperlinks.Add [a1], "http:\\excelworkshop.com\", _
      , "Go to Jeff's site.", "Excel Workshop"
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.