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!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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 · 1 years 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 · 2 years ago
    My hyperlink "text" is number only, and it doesn't work...
  • To post as a guest, your comment is unpublished.
    Brad Guiso · 2 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.
  • To post as a guest, your comment is unpublished.
    Regina Hardaway · 2 years ago
    I am trying to hide a sheet that has a hyperlink. I would like to be able to click on the sheet go to the hyperlink sheet and then click back to the sheet and close the hidden sheet. I have tried your instructions but it does not work. Not sure what I am doing wrong.