P
Philip J Smith
Hi.
Could some-one point out the error in the following code please?
I have used the code below to convert sheet names listed as lables into
hyperlinks, modifications noted in text. As the code was designed to convert
file links to hyperlinks rather than Worksheet names I have attempted to
modify it.
When run the code formats the lables as hyperlinks, but when I try to follow
the link the following error message appears.
"Reference is not Valid"
The worksheets are in the same workbook as their list. I have hardcoded the
workbook name, dangerous I know but I will sort that out once I get the code
working.
Regards
Phil
----------------------
Sub MakeHyperlinks_B()
'Copied from www.mvps.org/dmcritchie/excel/buildtoc.htm#MakeHyperLinks
'on 15 March 2007.
'Modified so that the range is in column B rather than D
'SubAddress Added to ActiveSheet.Hyperlinks
Dim cell As Range, Rng As Range
Set Rng = Range("B2:B" & Cells.Rows.Count). _
SpecialCells(xlConstants, xlTextValues)
If Rng Is Nothing Then
MsgBox "nothing in range"
Exit Sub
End If
For Each cell In Rng
If Trim(cell.Value) <> "" Then
ActiveSheet.Hyperlinks.Add Anchor:=cell, _
Address:="SummaryBilledByMonth.xls", _
SubAddress:=cell.Value, _
ScreenTip:=cell.Value, _
TextToDisplay:=cell.Value
End If
Next cell
End Sub
---------------------------
Could some-one point out the error in the following code please?
I have used the code below to convert sheet names listed as lables into
hyperlinks, modifications noted in text. As the code was designed to convert
file links to hyperlinks rather than Worksheet names I have attempted to
modify it.
When run the code formats the lables as hyperlinks, but when I try to follow
the link the following error message appears.
"Reference is not Valid"
The worksheets are in the same workbook as their list. I have hardcoded the
workbook name, dangerous I know but I will sort that out once I get the code
working.
Regards
Phil
----------------------
Sub MakeHyperlinks_B()
'Copied from www.mvps.org/dmcritchie/excel/buildtoc.htm#MakeHyperLinks
'on 15 March 2007.
'Modified so that the range is in column B rather than D
'SubAddress Added to ActiveSheet.Hyperlinks
Dim cell As Range, Rng As Range
Set Rng = Range("B2:B" & Cells.Rows.Count). _
SpecialCells(xlConstants, xlTextValues)
If Rng Is Nothing Then
MsgBox "nothing in range"
Exit Sub
End If
For Each cell In Rng
If Trim(cell.Value) <> "" Then
ActiveSheet.Hyperlinks.Add Anchor:=cell, _
Address:="SummaryBilledByMonth.xls", _
SubAddress:=cell.Value, _
ScreenTip:=cell.Value, _
TextToDisplay:=cell.Value
End If
Next cell
End Sub
---------------------------