VBA for Excel - link cell value to workshet via Hyperlink

vik2slick

New Member
Joined
Dec 28, 2017
Messages
23
Hi,

I have a workbook which has a worksheet named 'Index' that has Worksheet tab names in cells B5 to B44. How do I link each cell to a matching worksheet tab name without doing this manually?

Thank you in advance!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Maybe this
Change the Worksheet number in the code to the "Index" sheet number
Code:
Sub MM1()
For r = 5 To 44
Worksheets([color=red]1[/color]).Hyperlinks.Add anchor:=Worksheets([color=red]1[/color]).Cells(r, 1), Address:="", SubAddress:="'" & Worksheets([color=red]1[/color]).Cells(r, 1).Value & "'!B" & r & ""
Next r
End Sub
 
Upvote 0
Sorry Typo in Previous Post....use this instead

Code:
Sub MM1()
For r = 5 To 44
Sheets("Index").Hyperlinks.Add anchor:=Worksheets("Index").Cells(r, 2), Address:="", SubAddress:="'" & Worksheets("Index").Cells(r, 1).Value & "'!B" & r & ""
Next r
End Sub
 
Last edited:
Upvote 0
Hyperlink was created but I get an error when I click on the hyperlink = 'reference isn't valid' error
 
Upvote 0
Try

Code:
Sub MM1()
For r = 5 To 44
Sheets("Index").Hyperlinks.Add anchor:=Worksheets("Index").Cells(r, 2), Address:="", SubAddress:="'" & Worksheets("Index").Cells(r, 2).Value & "'!B" & r & ""
Next r
End Sub
 
Upvote 0
Michal,

When I click on the hyperlink for let's say cell B33, it takes me to the matching worksheet name but to cell B33. Anyway to go to that worksheet but to cell A1?
 
Upvote 0
Change to
Code:
Sub MM1()
For r = 5 To 44
Sheets("Index").Hyperlinks.Add anchor:=Worksheets("Index").Cells(r, 2), Address:="", SubAddress:="'" & Worksheets("Index").Cells(r, 2).Value & "'!A1"
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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