Go to Worksheet with Name Corresponding to Cell Value

angusfire

New Member
Joined
Feb 24, 2012
Messages
34
Morning All; I am in need of some assistance in creating a hyperlink or a Worksheet_BeforeDoubleClick sub that will go to a worksheet with a name that is the same as the value of a referenced cell.

For example:
[TABLE="width: 500"]
<tbody>[TR]
[TD]A1[/TD]
[TD]B1[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]B2[/TD]
[/TR]
</tbody>[/TABLE]

Double clicking or having a hyperlink in a cell in column B that will display the worksheet that has the name of the value in the cell in column A. The resulting worksheet is already created but it would be nice to be able to have it unhidden only when activated and then hidden when another worksheet is activated.

Thanks in advance,

angusfire
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You can simply right click the cell that you want to add the hyperlink
then go to "Hyperlink"
then select "Place in This Document"
And set the sheet that you want to hyperlink
 
Upvote 0
Well that was simple enough. It still would be nice to have the linked worksheet only be unhidden when active and then hidden when another link is chosen.

Thanks again,

angusfire
 
Upvote 0
This ended up working the best:

Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
 Dim shName As String
 If Left(Target.SubAddress, 1) = "'" Then
     shName = Mid(Target.SubAddress, 2, WorksheetFunction.Find("'", Target.SubAddress, 2) - 2)
 Else
     shName = Left(Target.SubAddress, WorksheetFunction.Find("!", Target.SubAddress) - 1)
 End If
 
 If Not Worksheets(shName).Visible Then
     Worksheets(shName).Visible = True
 End If
 
    For Each sh In ThisWorkbook.Sheets
     If sh.Name <> shName Then
         sh.Visible = False
     End If
    Next
    
    Worksheets("Exported Data").Visible = True
 
 With Worksheets(shName)
     .Activate
     .Range("A1").Select
 End With
 
 End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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