Hide Sheets/tabs from the cell ? Possible ?

audrey

Active Member
Joined
Jul 30, 2008
Messages
491
16if9dl.jpg



Hi,

I have an excel sheet that contains 120 tabs/sheets, but not all tabs are necesarily to be used.

I want to give the user flexibility to hide some of the sheets at the start sheet. Once he/she decides which sheets to be hidden with a simple Yes and No selection, I thought he/she can click the button and it hides all yes values. is that possible??? (and of course No values becomes unhidden)
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Example for a list in A1:B17:

Code:
Private Sub CommandButton1_Click()
    Dim Cell As Range
    For Each Cell In Range("A1:A17")
        With Cell
            Worksheets(.Value).Visible = .Offset(, 1).Value <> "Yes"
        End With
    Next Cell
End Sub

Change the range reference to suit.
 
Upvote 0
With a list of sheets starting in B4 and Yes/No in column C something like this should work

Code:
Sub HSheets()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 4 To LR
    Sheets(Range("B" & i).Value).Hidden = Range("C" & i).Value = "Yes"
Next i
End Sub
 
Upvote 0
Hi again, unless I am doing something really wrong, I couldnt make both work

w1a3r6.jpg





Column B is the sheet name and Column E are the Hide = Yes Unhide = No options
 
Last edited:
Upvote 0
Try

Rich (BB code):
Sub HSheets()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 6 To LR
    Sheets(Range("B" & i).Value).Hidden = Range("E" & i).Value = "Yes"
Next i
End Sub
 
Upvote 0
Try

Rich (BB code):
Sub HSheets()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 6 To LR
    Sheets(Range("B" & i).Value).Hidden = Range("E" & i).Value = "Yes"
Next i
End Sub


Run time error 438
Object does not support this method or property :confused:
 
Upvote 0
oops!

Rich (BB code):
Sub HSheets()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 6 To LR
    Sheets(Range("B" & i).Value).Visible = Range("E" & i).Value = "No"
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top