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!


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.
    Walido Lido · 5 months 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