Error when hyperlinking Excel cells to worksheets based on the cell values for sheets whose name in
I have written following macro to hyperlink Excel cells to worksheets based on the cell value. It failes to work for sheets whose name include “-“. (See cell A4 in the excel attachment.)
Can you guide me on this issue?
Sub FShyeperlink()
On Error Resume Next
Dim n As Integer
Dim i As Integer
Dim rng As Range
n = Selection.Rows.Count
Set rng = Selection
Selection.Hyperlinks.Delete
For i = 1 To n
rng(i).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
Selection.Value & "!A1"
Next i
End Sub
|