How to Hide and Unhide tabs according to cell criteria.

Solved/Closed
SimplemindedDwight Posts 3 Registration date Monday April 20, 2015 Status Member Last seen May 19, 2015 - May 19, 2015 at 12:10 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - May 20, 2015 at 02:03 AM
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.
Related:

1 response

vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 262
May 20, 2015 at 02:03 AM
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.
0