News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Use VBA code to make a hyperlink in Excel

Started by nandagopal, Nov 03, 2008, 05:12 PM

Previous topic - Next topic

nandagopal

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