hyperlink to hidden excel pages within a workbook

djeffery

New Member
Joined
Dec 16, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I have a workbook that has multiple sheets in it. On my main page I have buttons that when clicked follow a hyperlink to another page. I would like to be able to hide all of the pages but still hyperlink to those pages. I have tried multiple versions of code to accomplish this, but none of them will work. Any help would be greatly appreciated.





Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

On Error GoTo FixThings

Dim strAddress As String

strAddress = Application.WorksheetFunction.Substitute(Target.SubAddress, "'", vbNullString)

ThisWorkbook.Worksheets(VBA.Left$(strAddress, VBA.InStr(1, strAddress, "!") - 1)).Visible = xlSheetVisible

Application.EnableEvents = False

Target.Follow

FixThings:

Application.EnableEvents = True

End Sub









Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

'Updateby Extendoffice

Application.ScreenUpdating = False

Dim strLinkSheet As String

If InStr(Target.Parent, "!") > 0 Then

strLinkSheet = Left(Target.Parent, InStr(1, Target.Parent, "!") - 1)

Else

strLinkSheet = Target.Parent

End If

Sheets(strLinkSheet).Visible = True

Sheets(strLinkSheet).Select

Application.ScreenUpdating = True

End Sub







Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Dim shtName As String

'shtName = Target.Name

shtName = Left(Target.SubAddress, InStr(1, Target.SubAddress, "!") - 1)

Sheets(shtName).Visible = xlSheetVisible

Sheets(shtName).Select



End Sub







Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

LinkTo = Target.SubAddress

WhereBang = InStr(1, LinkTo, "!")

If WhereBang > 0 Then

MySheet = Left(LinkTo, WhereBang - 1)

Worksheets(MySheet).Visible = True

Worksheets(MySheet).Select

MyAddr = Mid(LinkTo, WhereBang + 1)

Worksheets(MySheet).Range(MyAddr).Select

End If

End Sub
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,664
Welcome to the board!

I think there might be a lot easier (?) solution to your problem: What if - instead of hiding the worksheets - you'd just hide the worksheet tabs? The sheets would still be there but you couldn't see / access them without using the hyperlinks.

To hide the tabs select the Advanced from the Excel Options (File -> Excel Options -> Advanced) and scroll down to the Display options for this workbook section. Uncheck the Show sheet tabs selection and you're done.

Just remember to create your hyperlinks before hiding the tabs.
 

djeffery

New Member
Joined
Dec 16, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Very nice. Simple is always better. Works great. Seems to fit my need.

Thanks for you help.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,236
Messages
5,594,984
Members
413,955
Latest member
FalcoDaz

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
Top