Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse VBA code to make a hyperlink in Excel
DescriptionThis example shows how to use VBA code to make a hyperlink in Excel.
KeywordsVBA, Excel, hyperlink, link
CategoriesOffice, 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
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated