Toggle Button to hide / unhide multiple sheets

PVA0724

New Member
Joined
Apr 21, 2012
Messages
48
Hi

I'm new using the user forms so I have this procedure that hide / unhide to specific workshets...so I thought that if copy to the Private Sub of the ToggleButton will work the same...but it didn't...and here it is the code I used

Code:
 Private Sub ToggleButton1_Click()
 Dim ws As Worksheet
    For Each ws In Sheets(Array("ICP account Express List", "ICP Participants"))
        ws.Visible = (ws.Visible = False)
    Next ws

End Sub

Any idea how to get it, so that if I click the first time both worksheets will be hidden and in a second one visible

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You can use:

ws.Visible = Not ws.Visible

If you want it for general use, then remove the Private.

HTH,
 
Upvote 0
Hi

Thanks for the prompt reply I did the change as follow

Code:
Dim ws As Worksheet
    [B][COLOR=#0000ff]For Each ws In Sheets(Array("ICP account Express List", "ICP Participants"))
[/COLOR][/B]       ws.Visible = Not ws.Visible
   Next ws

And now I'm getting Subscript out of range in the blue line. I only these worksheets to have them visible or not from the user form toggle button.
 
Upvote 0
Hi Smitty

Yes, they are, what I did was to tested that as a producedure and it worked, so that's why I just copy it to the toggle button instruction, but it didn't work.
 
Upvote 0

Forum statistics

Threads
1,222,149
Messages
6,164,238
Members
451,882
Latest member
Bigtop

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