Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to follow hyperlink to hidden sheet in Excel?

For example, I have a workbook which contains multiple worksheets, the first master sheet has hyperlinks to other sheets, and now, I hide all sheets except the first one. In this case, the hyperlinks which link to hidden sheets are not available. But, how could you make these hyperlinks work successfully? When you click one hyperlink, the linked hidden sheet will be opened at once as following screenshot shown:

doc hyperlink to hidden sheet 1

Follow hyperlink to open hidden sheet with VBA code

Follow hyperlink to open hidden sheet and then hide it again with VBA code


List all worksheet names and link to each sheet:

With Kutools for Excel's Create List of Sheet Names utility, you can quickly list all worksheet names in a new sheet with hyperlinks or macro buttons as you need.

    worksheet names with hyperlinks   worksheet names with macro buttons
doc-list-worksheet-names2  2 doc-list-worksheet-names2  2 doc-list-worksheet-names2

Follow hyperlink to open hidden sheet with VBA code


The following VBA code may help you to open the hidden worksheet when clicking its relative hyperlink, please do as this:

1. Right click the sheet tab that you want to follow the hyperlink to hidden sheet, and then choose View Code from the context menu, in the popped out Microsoft Visual Basic for Applications window, please copy and paste the following code into the blank Module:

VBA code: Follow hyperlink to open hidden sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20161109
    Application.ScreenUpdating = False
    On Error Resume Next
    If Target.Column = 1 Then
        Sheets(Target.Value).Visible = xlSheetVisible
        Sheets(Target.Value).Select
    End If
    Application.ScreenUpdating = True
End Sub

doc hyperlink to hidden sheet 2

Note: In the above code, the number 1 in this If Target.Column = 1 Then script indicates the column number which contains the hyperlinks, please change it your need.

2. Then save and close this code window, now, when you click the hyperlink which link to the specific hidden sheet, the hidden sheet will be opened at once.


Follow hyperlink to open hidden sheet and then hide it again with VBA code

Sometimes, you need to follow the hyperlink to open the hidden sheet, and when you go back the master sheet, you want the opened sheet to be hidden again. The below VBA code can do you a favor:

1. Right click the sheet tab that you want to follow the hyperlink to hidden sheet, and then choose View Code from the context menu, in the popped out Microsoft Visual Basic for Applications window, please copy and paste the following code into the blank Module:

VBA code: Follow hyperlink to open hidden sheet when go back hide it again:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
   'Updateby Extendoffice 20161109
    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_Activate()
    On Error Resume Next
    Sheets(ActiveCell.Value2).Visible = False
End Sub

doc hyperlink to hidden sheet 3

2. Then save ad clos the code window, when you click the hyperlink, the linked hidden sheet will be opened immediately, but, if you go back the master sheet which contains the hyperlinks, the opened sheet will be hidden automatically again.

Note: Theses codes are only applied to the sheet names which match your hyperlink text.


Demo: Follow hyperlink to open hidden sheet with VBA code

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Ken · 9 months ago
    I would like to use this code but only want it to apply to column A. I have other web address links in other cells which cause a problem when running this code.
  • To post as a guest, your comment is unpublished.
    DNKP · 1 years ago
    My hyperlink "text" is number only, and it doesn't work...
  • To post as a guest, your comment is unpublished.
    Brad Guiso · 1 years ago
    I'm using the code on two different sheets. It works for one of about 40 hyperlinks on one sheet and it opens two of about 10 hyperlinks one she second, the sheets on the second which do open do go back into hiding when I return to the sheet.

    The error I get when it will not open a sheet is Run-time error"9": script out of range and the code it points me to - Sheets(strLinkSheet).Visible = True

    Any ideas as to what change is needed make the code work on all of the sheets?

    Thank you in advance.
  • To post as a guest, your comment is unpublished.
    HelzBelz · 2 years ago
    I have used this code on two different sheets in my workbook, and in both cases it works great, except for the first hyperlink on each page. I get "Subscript out of range error" and the debugger points to the "Sheets(strLinkSheet).Visible = True" right after the "end if".

    Anyone else see this error? It is only on the first link on the page. (my hyperlinks are in column A, and start in row 2)
    • To post as a guest, your comment is unpublished.
      Bumi · 2 years ago
      [quote name="HelzBelz"]I have used this code on two different sheets in my workbook, and in both cases it works great, except for the first hyperlink on each page. I get "Subscript out of range error" and the debugger points to the "Sheets(strLinkSheet).Visible = True" right after the "end if".

      Anyone else see this error? It is only on the first link on the page. (my hyperlinks are in column A, and start in row 2)[/quote]
      Sheet names can't have space like "Sheet 1". I fixed my sheet names to "Sheet1" and the error stopped.
  • To post as a guest, your comment is unpublished.
    Regina Hardaway · 2 years ago
    I have a sheet that is hidden that contains a hyperlink. I would like to be able go to the hidden sheet and have it close when I go back to the original sheet. I used the code but it does not work.