How to Hide and Unhide tabs according to cell criteria. [Solved/Closed]

Report
Posts
4
Registration date
Monday April 20, 2015
Status
Member
Last seen
May 19, 2015
-
Posts
1278
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
February 16, 2021
-
Hello,

I have an Invoice that has a Rent To Own Sheet and also an Order Form attached to it. On my the Order Form tab I have a data validation box with a title "RTO" that has the option for "RTO" or "CUSTOMER PURCHASE". If you choose "RTO" then the Rent To Own Sheet becomes visible. If you choose "CUSTOMER PURCHASE" then the Rent To Own Sheet is hidden. Any suggestion would be deeply appreciated. Thanks.

1 reply

Posts
1278
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
February 16, 2021
221
Hello SMD,

In the worksheet module (right click on the "Rent to Own" sheet" and select "view code") then place this code in the big white field:-

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A1") <> "RTO" Then
Sheets("Rent to Own").Visible = False
End If

End Sub


As you can see from the code, the data validation box is assumed to be in cell A1. Change this to suit yourself.

To unhide, right click on any tab and select "unhide" or, if you prefer, place this code in a standard module:-

Sub Unhide()

Sheets("Rent to Own").Visible = True
Sheets("Rent to Own").Select

End Sub


I hope that this helps.

Cheerio,
vcoolio.

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!