Hiding same Columns using a toggle button over 12 worksheets using VBA code on the toggle button.

PMRetired2012

Board Regular
Joined
Aug 6, 2019
Messages
123
What i want to do is hide the same columns on multiple worksheets using a toggle button. i cant figure out the proper code to attach to the button. i can find code to get it for one worksheet but i have 12 i wnat to hide columns f so i can print with them hidden the toggle the button to put the columns back in.

Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Do you want to hide the column on all sheets or just some?
If just some, how many sheets are there in the workbook?
 
Upvote 0
i wnat hide the column on some sheets.
There are a total of 15 workwheets but i only want to hide columns on 12 of the sheets.
The columns i want to hide are: U:X and AG:AI
Thanks
 
Upvote 0
Ok, how about
VBA Code:
Private Sub ToggleButton1_Click()
   Dim ws As Worksheet
   
   For Each ws In Worksheets
      Select Case ws.name
         Case "a", "b", "c"
         Case Else
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
      End Select
   Next ws
End Sub
Change the a,b & c to the names of the sheets that should not be affected.
 
Upvote 0
Fluff i want to say the code you gave me worked correctly.. Thanks
OK i posted another question earlier but didnt get any responce.
What im wanting to do is print in duplex. i am using the syntex (ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,1,,,TRUE,,FALSE)" for the printing now in my macro.
I understand there isnt a option if im using this code to have it print in duplex.
so what kind of code can you give me to print in duplex over 24 pages?
i posted this earlier you might want to go find it and maybe you can answer it if there is a answer.

thanks
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Yes I did, but cannot help.
 
Upvote 0
Nope, I have no idea who might know about that sort of thing.
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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