Hello Chandoo Forumers!
Disclaimer: I know little to nothing about VBA but I know enough to know I need it!
My ultimate goal is to hide all worksheets except the main Dashboard when my file is opened and unhide each worksheet when a text box with a hyperlink is selected. The sheet should be hidden again once the "Return to Menu" text box is selected. The Main Dashboard can stay active all the time (or doesn't have to if that complicates matters). I think I would like to use very hidden so users can not simply unhide sheets.
I tried the below code from Hui which I found in a similar post (http://forum.chandoo.org/threads/ho...s-when-clicked-on-main-sheet.4640/#post-24566) but even after replacing Main with my worksheet name it gave a compile error (Expected: Expression) at the # before 60.
I have attached a sample file. My real file has probably 20 more worksheets but only included a few for simplicity.
I hope someone enjoys the challenge and can help out.
Thanks for your time,
B
Disclaimer: I know little to nothing about VBA but I know enough to know I need it!
My ultimate goal is to hide all worksheets except the main Dashboard when my file is opened and unhide each worksheet when a text box with a hyperlink is selected. The sheet should be hidden again once the "Return to Menu" text box is selected. The Main Dashboard can stay active all the time (or doesn't have to if that complicates matters). I think I would like to use very hidden so users can not simply unhide sheets.
I tried the below code from Hui which I found in a similar post (http://forum.chandoo.org/threads/ho...s-when-clicked-on-main-sheet.4640/#post-24566) but even after replacing Main with my worksheet name it gave a compile error (Expected: Expression) at the # before 60.
I have attached a sample file. My real file has probably 20 more worksheets but only included a few for simplicity.
Code:
Sub Worksheet_Activate()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Main" Then ws.Visible = False 'Change this worksheet name to suit
Next
End Sub
The Worksheet_FollowHyperlink module will use the Link in the hyperlink to extract the Worksheet name and then use that to unhide the sheet and select it
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim mysheet As String
mysheet = Left(Target.Name, InStr(1, Target.Name, "!") - 1)
Worksheets(mysheet).Visible = True
Worksheets(mysheet).Activate
End Sub
I hope someone enjoys the challenge and can help out.
Thanks for your time,
B