Hyperlink Macro that converts a list of sheet names to hyperlinks to the sheets

holt3130

New Member
Joined
Jul 23, 2013
Messages
14
Hey,

I am having trouble getting a macro to do what I want.

In column A i have a list of the sheet names in the workbook

I need a macro that will take the text from the cell and convert it to a hyperlink to its corresponding sheet

for example in cell A1 there is the text "SP5M"
there is also a sheet named "SP5M"
I want a macro to take the text from the cell that I have selected, tack on the "!A1" so it becomes an address for the sheet and create a hyperlink that displays just the original name...

if that makes sense?
 
I just wanted to send out a big THANK YOU! This worked brilliantly for me.

I found this thread as it *almost* provides what I've been trying to figure out for a while. I need the macro to turn text in column B into hyperlinks to sheets which are named in column A, and I can't figure out how to adjust the above to do it (my VBA skills are extremely limited and rely on me reverse engineering similar code). Ideally I also need the macro to work in any sheet I run it in without having to adjust the macro for each sheet I need to create links in.

Can anyone help?
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I found this thread as it *almost* provides what I've been trying to figure out for a while. I need the macro to turn text in column B into hyperlinks to sheets which are named in column A, and I can't figure out how to adjust the above to do it (my VBA skills are extremely limited and rely on me reverse engineering similar code). Ideally I also need the macro to work in any sheet I run it in without having to adjust the macro for each sheet I need to create links in.

Hi, you could give this a try.

Code:
Sub m()
Dim c As Range
For Each c In Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    c.Hyperlinks.Add c, "", "'" & c.Offset(, -1).Value & "'!A1", c.Value
Next c
End Sub
 
Upvote 0
Hi, you could give this a try.

Code:
Sub m()
Dim c As Range
For Each c In Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    c.Hyperlinks.Add c, "", "'" & c.Offset(, -1).Value & "'!A1", c.Value
Next c
End Sub

I adjusted the cell values (including !A1 to !B1) and then it worked perfectly, thank you so much!
 
Upvote 0
Give this a try:
Rich (BB code):
Sub Test()
Dim i As Long
    With Sheets("Sheet1")
        For i = 1 To .Range("A" & .Rows.Count).End(xlUp).Row
        .Hyperlinks.Add Anchor:=.Range("A" & i), Address:="", _
        SubAddress:="'" & .Range("A" & i).Value & "'!A1", TextToDisplay:=.Range("A" & i).Value
        Next i
    End With
End Sub

Change the sheet name to the sheet that contains your list.

Try on a copy of your workbook.

Need very much the same. Just tried the code in excel 2016 and it gave a Runtime error 5: Invalid procedure call or argument. Any clue?
J
 
Upvote 0
Any clue?

Hi, try this alternative.

Assumes your sheet names are in column A starting on row 2

Code:
Sub m()
Dim c As Range
For Each c In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
    c.Hyperlinks.Add c, "", "'" & c.Value & "'!A1", CStr(c.Value)
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,370
Messages
6,136,154
Members
449,994
Latest member
Rocky Mountain High

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top