Hi all, I am new here but have found good information in the past from this site.
I am creating a data-integrated sheet for my company that simply has a menu page with hyperlinked cells to travel to hidden corresponding sheets. The hidden sheets then have a "Back to Menu" hyperlink that re-hides the sheet. The Menu Page vba script for unhiding/go-to the hidden sheet(s) works for the first few links, then bugs out from the 5th link on (Run-time error '9': Subscript out of range).
Debugging shows the error here:
The code for each page that hyperlinks back to the menu and re-hides is:
Like I said, this works great for the first few links, then I get the error. Any help would be greatly appreciated!
I am creating a data-integrated sheet for my company that simply has a menu page with hyperlinked cells to travel to hidden corresponding sheets. The hidden sheets then have a "Back to Menu" hyperlink that re-hides the sheet. The Menu Page vba script for unhiding/go-to the hidden sheet(s) works for the first few links, then bugs out from the 5th link on (Run-time error '9': Subscript out of range).
Debugging shows the error here:
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
LinkTo = Target.SubAddress
WhereBang = InStr(1, LinkTo, "!")
If WhereBang > 0 Then
mysheet = Replace(Left(LinkTo, WhereBang - 1), "'", "")
[COLOR=rgb(184, 49, 47)] [B] [/B][/COLOR]Worksheets(mysheet).Visible = True <------------ error is here
Worksheets(mysheet).Select
MyAddr = Mid(LinkTo, WhereBang + 1)
Worksheets(mysheet).Range(MyAddr).Select
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Hyperlinks.Count > 0 Then
Target.Hyperlinks(1).Follow
End If
End Sub
The code for each page that hyperlinks back to the menu and re-hides is:
VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Worksheets("INQUIRE").Select
Target.Parent.Worksheet.Visible = False
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Hyperlinks.Count > 0 Then
Target.Hyperlinks(1).Follow
End If
End Sub
Like I said, this works great for the first few links, then I get the error. Any help would be greatly appreciated!
Last edited by a moderator: