|
|
Title | Use VBA code to make a hyperlink in Excel |
Description | This example shows how to use VBA code to make a hyperlink in Excel. |
Keywords | VBA, Excel, hyperlink, link |
Categories | Office, Multimedia |
|
|
Subroutine MakeLink adds a hyperlink to the active worksheet. It calls the Hyperlinks collection's Add method, passing it the link's cell, URL, tooltip text, and display text.
|
|
Sub MakeLink(ByVal cell As Range, ByVal url As String, _
ByVal txt As String, ByVal tooltip_text As String)
ActiveSheet.Hyperlinks.Add _
Anchor:=cell, _
Address:=url, _
ScreenTip:=tooltip_text, _
TextToDisplay:=txt
End Sub
|
|
Subroutine RemoveLink removes the hylerlink from a cell. Note that this does not erase the cell's text. To do that, call the cell's Clear method.
|
|
Sub RemoveLink(ByVal cell As Range)
cell.Hyperlinks.Delete
End Sub
|
|
|
|
|
|