Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a main tab with a long list of companies. I then have individual tabs for each company with in-depth data. I’m looking for a way to have a hyperlink connect each company to its individual tab however it would take a long time to individually link each cell to its corresponding tab. Is there a way to highlight the list of companies and then hyperlink them to their sequential corresponding tab? Or some other way to link them rather than doing one by one.

If the company names in the cells that contain your list match the sheet name for each company exactly, then something like the following code should work. The order of the list doesn't have to match the order of the sheets, but the names must match exactly.
(You would need to change the first line to match the range that contains your list of company names.)
Sub Hyperlinker()
For Each cName In Sheets(1).Range("A1:A4")
ActiveSheet.Hyperlinks.Add Anchor:=cName, Address:="", SubAddress:= _
cName & "!A1", TextToDisplay:=cName.Value
Next
End Sub
If the list of names is in the same order as the sheets, then this code should work. It doesn't matter if the names match or not. The main assumption is that your list starts in Sheet1!A1 and that A1 should be hyperlinked to Sheet2, A2 hyperlinked to Sheet3, etc.
Sub Hyperlinker()
ShtNum = 1
For Each cName In Sheets(1).Range("A1:A4")
ShtNum = ShtNum + 1
ActiveSheet.Hyperlinks.Add Anchor:=cName, Address:="", SubAddress:= _
Sheets(ShtNum).Name & "!A1", TextToDisplay:=cName.Value
Next
End Sub

That sounds like it would work perfectly since they are all in the same order and have the exact names. Can you guide on how to add the code. Im not familiar with access coding and have never done anything like this before.

Assuming your "main tab" is Sheet1 try this:
1 - Make a back-up copy of the workbook in case it blows up.
2 - Make a back-up copy of the workbook in case it blows up. (You heard that, right? If you didn't, don't blame me.)
3 - Right click the sheet tab for Sheet1 and click on View Code.
4 - Paste this code into the window that opens:
Sub Hyperlinker()
ShtNum = 1
For Each cName In Sheets(1).Range("A1:A4")
ShtNum = ShtNum + 1
ActiveSheet.Hyperlinks.Add _
Anchor:=cName, Address:="", SubAddress:= _
Sheets(ShtNum).Name & "!A1", _
TextToDisplay:=cName.Value
Next
End Sub5 - If any of the code turns red, it won't work, so either fix it by addig carriage retruns where you need them or post back.
6 - Change Range("A1:A4") to be the actual range of your list. They must be the same size - i.e. 25 names and 25 sheets not counting Sheet1. If you have a header row or if the list doesn't start in A1, you'll need to adjust for that.
7 - Put yoru cursor anywhere within the code and Click Run...Run Sub/Userform or hit F5.
8 - Post back whatever errors you get or problems you have, cuz I doubt it'll work right the first time.
You did make a back up copy of the workbook, didn't you?

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |