VBA If Multiple Sheets Are Visible Then Very Hidden Else Visible

Lewzerrrr

Active Member
Joined
Jan 18, 2017
Messages
256
Hi,

I've tried to come up with this code but it won't work - can anyone advice please? Trying to make a button that will hide and unhide the sheets below however need it to be very hidden.. I can make it work with normal hidden but this allows the user to unhide manually which I don't want to happen.

Thanks,

Code:
Sub Button1_Click()

'Dim PW As String


'PW = InputBox("Please enter the password")


'If PW = "****" Then


Application.ScreenUpdating = False


For Each sh In Sheets(Array("Clothing (frag)", "Clothing (All)", "Sub Brand Clothing (Frag)", "Sub Brand Clothing (All)", "Non Clothing (Frag)", "Non Clothing (All)"))
If sh.Visible = xlVisible Then
sh.Visible = xlVeryHidden
Else
sh.Visible
End If
Next


Sheets("Area Summary").Activate


Application.ScreenUpdating = True


'Else


'MsgBox "Password incorrect. Please try again."


'End If


End Sub
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Nvm solved it :D

Code:
On Error Resume NextFor Each sh In Sheets(Array("Clothing (frag)", "Clothing (All)", "Sub Brand Clothing (Frag)", "Sub Brand Clothing (All)", "Non Clothing (Frag)", "Non Clothing (All)"))
If sh.Visible = True Then
sh.Visible = xlVeryHidden
Else
sh.Visible = True
End If
Next
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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