Unhide and hide sheet using hyperlink

russelldt

Board Regular
Joined
Feb 27, 2021
Messages
158
Office Version
  1. 365
Platform
  1. MacOS
Hello. I have a master tab (Index) which contains a number of hyperlinks to other sheets (in the same file). All the sheets are hidden. I would like to be able to click the hyperlinked to unhide a sheet , and then when I exit the file, all the unhidden sheets (except the Index) are hidden.

Can anyone help me with this,

Thanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Create your hyperlinks - AFAIK it won't matter which sheet you pick as the target for the hyperlinks but you might as well pick the sheet name that the link will point to. The text to display should be the name of the sheet you want to unhide.

In workbook module to hide all but "Index" at closing try:
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet

For Each ws In Sheets
   If ws.Name <> "Index" Then ws.Visible = False
Next

End Sub
On your Index sheet module create procedure
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Sheets(Target.Name).Visible = True

End Sub
 
Upvote 0
Solution
I think this should be
VBA Code:
For Each ws In Worksheets
 
Upvote 0
Create your hyperlinks - AFAIK it won't matter which sheet you pick as the target for the hyperlinks but you might as well pick the sheet name that the link will point to. The text to display should be the name of the sheet you want to unhide.

In workbook module to hide all but "Index" at closing try:
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet

For Each ws In Sheets
   If ws.Name <> "Index" Then ws.Visible = False
Next

End Sub
On your Index sheet module create procedure
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Sheets(Target.Name).Visible = True

End Sub
Perfect, many thanks Micron
 
Upvote 0
You're welcome. If it worked for you, can you mark this one as solved?
Thanks.
 
Upvote 0
Well, that's interesting that you marked your acceptance of the solution using your thank you post! :eek:
 
Upvote 0
NP. Just trying to double my pay rate here by accumulating brownie points. ;)
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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