Open Hidden Worksheet
You need to handle two different events. Put this code in the worksheet module that has the hyperlink(s)
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink
Worksheets(Left(Target.SubAddress, InStr(1, Target.SubAddress, "!") - 1)).Visible = xlSheetVisibl
Application.EnableEvents = Fals
Target.Follo
Application.EnableEvents = Tru
End Su
And put this code in the Worksheet module of the worksheet that you want to hide when deactivated
Private Sub Worksheet_Deactivate(
Me.Visible = xlSheetHidde
End Su
This functionality is kinda "rigged". The FollowHyperlink event is invoked twice, with the second one turned off to prevent a sort of recursion. The first pass to make the sheet visible, and the second pass to follow the hyperlink, since the first pass will not work on an invisible worksheet. Which indicates that the Follow method of the Hyperlink object is executed prior to the firing of the FollowHyperlink event. That's kinda silly, but there it is
The rigging that I put in there will not work if the sheet name you've hidden has an Exclamation point in it. If you do you have a bang in there, you'll need to make a function to return the target sheet name from the subaddress that is a little more robust than the bungle I put in there. Post back if you need help with that
I hope that helps
-Brad Vontur
|