Unhide specific tabs via hyperlink

povictory

New Member
Joined
May 28, 2015
Messages
45
Hello,

I have a tab where I have 20 hyperlinks to other tabs in the same document. I have 7 of those tabs hidden initially and I would like them to appear, select the sheet, and stay visible when their corresponding hyperlink is clicked. I was able to figure out how add code to make them appear when the link is clicked, however I know I need to add something else because now anytime I click on *any* of the 20 links, the result is that Sheet24 is selected, which I believe is because it is the last line of code so that is where the selection will always end up. I'm still a novice at this so I can't figure what I need to add/change to make it so that the selection goes to Sheet26 when the corresponding Sheet26 link is clicked, Sheet14 when the Sheet14 link is clicked, and so on. Not sure how to make the code "ignore" the other commands that come later in the code and are irrelevant to the link being clicked. I hope that makes sense but if there is anything I can do to clarify, let me know. Any assistance is greatly appreciated!

VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

  'Unhide Rollup Comparison when Hyperlink is clicked
  Sheet26.Visible = xlSheetVisible
  Sheet26.Select
  
  'Unhide Pg1 Comparison when Hyperlink is clicked
  Sheet14.Visible = xlSheetVisible
  Sheet14.Select
  
  'Unhide Pg2 Comparison when Hyperlink is clicked
  Sheet16.Visible = xlSheetVisible
  Sheet16.Select
  
  'Unhide Pg3 Comparison when Hyperlink is clicked
  Sheet18.Visible = xlSheetVisible
  Sheet18.Select
  
  'Unhide Pg4 Comparison when Hyperlink is clicked
  Sheet20.Visible = xlSheetVisible
  Sheet20.Select
  
  'Unhide Pg5 Comparison when Hyperlink is clicked
  Sheet22.Visible = xlSheetVisible
  Sheet22.Select
  
 'Unhide Pg6 Comparison when Hyperlink is clicked
  Sheet24.Visible = xlSheetVisible
  Sheet24.Select
      
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
try this instead of your code, it detects which sheet from the hyperlink
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ii = Target.Name
it = InStr(ii, "!") - 1
shtname = Left(ii, it)

Worksheets(shtname).Visible = xlSheetVisible
Worksheets(shtname).Select
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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