View Single Post
 
Old 03-27-2017, 06:12 AM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

I used the macro recorder to see how/where Excel uses the sheet name.
Give this a try...
Code:
Sub createHyperlinks_2()
'
' Macro to create hyperlinks
'
'
Dim tocText As String       ' variable to hold text to appear in table of contents
Dim sh As String            ' holds name of worksheet to be linked to
Dim selectedCell As Range   ' holds cell reference of cell I want to be linked to

sh = ActiveSheet.Name
Set selectedCell = ActiveCell
tocText = ActiveCell.Text
Sheets("Table of Contents").Select

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", _
        SubAddress:=sh & "!" & selectedCell.Address, TextToDisplay:=tocText

End Sub
Reply With Quote