Hyperlink linking ot the wrong worksheet

ctiger

New member
Joined
Nov 4, 2013
Messages
16
Reaction score
0
Points
0
Excel Version(s)
2013
Have an unusual problem that I can't figure out with hyperlinks. I have a main page (a directory for all the sheets) which is hyperlinked to numerous sheets and all have hyperlinks to take me back to the main page. My problem is on one sheet I also have a hyperlink with a vba to unhide a sheet for viewing and a vba on the hidden sheet to re-hide it and take me back to the sub-sheet (if that makes sense). My problem is when I click on the hyperlink on this sub-sheet to take me back to the main sheet it keeps going to the hidden sheet! My code on the sub-sheet to unhide the one sheet is:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
LinkTo = Target.SubAddress
WhereBang = InStr(1, LinkTo, "!")
If WhereBang > 0 Then
priorsampleprojects = Left(LinkTo, WhereBang - 1)
Worksheets("priorsampleprojects").Visible = True
Worksheets("priorsampleprojects").Select
MyAddr = Mid(LinkTo, WhereBang + 1)
Worksheets("priorsampleprojects").Range(MyAddr).Select
End If

End Sub


The code on the hidden sheet is:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Worksheets("memosamples").Select
Target.Parent.Worksheet.Visible = False

End Sub

Why can't I get the non vba hyperlink to take me to the main sheet?

Thanks Gene
 
Back
Top