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 hide or unhide a specific worksheet based on cell value in another sheet?

Are there any methods for us to hide or unhide a specific worksheet tab based on a cell content in another sheet? For example, when I enter the text “Yes” in the cell G1 of Sheet2, I want the Sheet1 to be hidden, and when I enter “No”, the Sheet1 to be displayed at once. How could I solve this problem in Excel?

Hide or unhide a specific worksheet tab based on cell value with VBA code

Hide or unhide all other worksheet except the active one with Kutools for Excel


arrow blue right bubble Hide or unhide a specific worksheet tab based on cell value with VBA code


To hide or unhide a specific worksheet tab based on a cell value in another worksheet, the following VBA code may do you a favor, please do as follows:

1. Go the worksheet which contains the cell value you want to hide another sheet based on.

2. Right click the sheet tab, and select View Code, in the popped out Microsoft Visual Basic for Applications window, please copy and paste the following code into the blank Module window, see screenshot:

VBA code: Hide or hide a worksheet tab based on cell value:

Private Sub Worksheet_Change(ByVal Target As Range)
If [G1] = "Yes" Then
Sheets("Sheet1").Visible = True
Else
Sheets("Sheet1").Visible = False
End If
End Sub

doc hide tab based on cell value 1

Note: In the above code, G1 and Yes are the cell and cell content that you want to base on, and Sheet1 is the specific sheet that you want to hide or unhide. You can change them to your need.

3. Then save and close this code, when you enter “No” or other text in cell G1, Sheet1 is hidden, but if you enter “Yes” in the cell, Sheet1 is displayed at once, see screenshots:

doc hide tab based on cell value 2
 1
doc hide tab based on cell value 3

arrow blue right bubble Hide or unhide all other worksheet except the active one with Kutools for Excel

In Excel, you may need to hide all other worksheet tabs and only leave the active sheet displaying, to hide them one by one will not a good choice, here, I can recommend a useful tool-Kutools for Excel, with its Hide Unselected Sheets utility, you can hide all other worksheet except the active one with one click.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as follows:

1. Go to the worksheet that you want to display, and click Kutools > Show / Hide > Hide Unselected Sheets, see screenshot:

doc hide tab based on cell value 4

2. And all sheet tabs are hidden at once except the active one, see screenshot:

doc hide tab based on cell value 5

Note: If you want to unhide them, you just need to click Kutools > Show / Hide > Unhide All Sheets to display the hidden sheets immediately.

doc hide tab based on cell value 6

Free Download Kutools for Excel 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.
    Walido Lido · 1 years ago
    Hello
    Thank you for the tip. I need to do the same scenario but not on one cell only (G1 in this case) but on all cells of column G. I have tried with "Range" but it didn't work.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("X2:X100") = "" Then
    Sheets("EU TASK BASED MEASUREMENTS").Visible = False
    Else
    Sheets("EU TASK BASED MEASUREMENTS").Visible = True
    End If
    End Sub


    Thank you in advance
    • To post as a guest, your comment is unpublished.
      Scott Hobin · 2 months ago
      Any chance this was answered? I am also running into this scenario where a whole range comes into play instead of just one cell... I used this same coding with the same results.