View Single Post
 
Old 07-31-2023, 08:02 PM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Jun 2021
Posts: 124
soroush.kalantari is on a distinguished road
Default 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
Attached Files
File Type: xlsm sheethyperlink.xlsm (18.6 KB, 4 views)
Reply With Quote