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
 
Nope, I have no idea who might know about that sort of thing.
Fluff,
I have another question along the lines of hiding. I want to hide 3 rows (1,2,3) on a spefic sheet in the work book. i would like to be able to hide those rows by using the same button at the same time when i hide the columns that you sent me the code for earlier that worked so well.
Im not sure what the code would be or if i can do that
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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 "d"
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
            ws.Rows("1:3").Hidden = Not ws.Rows("1:3").Hidden
         Case Else
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
      End Select
   Next ws
End Sub
 
Upvote 0
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 "d"
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
            ws.Rows("1:3").Hidden = Not ws.Rows("1:3").Hidden
         Case Else
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
      End Select
   Next ws
End Sub
I dont think i said what the name of the page i want the rows hidden on. the workbook has 15 worksheets. the code you gave me didnt mention the page name or tab name.
the page name is YTD info. I think that would make a diffrentce on what rows you hide on which page. Let me know

Thanks
 
Upvote 0
I know you didn't, see post#4
Well on post 4 i didnt see how to name the page i want to hide rows on. If you dont mind show me all the code with the name of page inserted in the code. i think the problem will be in the code you just gave me one of the pages i wanted to not hide is one of the pages i want the rows hidden on.
 
Upvote 0
How? I have no idea what your sheet names are, or which sheets should do what!
ok the sheet names are: (January,Febuary,march,April,May,June,July,August,September,October,November,December,YTD NFO,OPTIONS PAGE,NEW EQUIP REPAIRS) 15 worksheets.
Now what i want to do is:
1. Hide those columns as stated before in the previous post (ux:ag) for the months of Jan:Dec. using a toggle button. That all works just fine.
2. im wanting the same toggle button to hide collums (UX:AG) as previous stated as working good and add the rows 45:48 on worksheet YTD INFO.
3 so what you will have is when you hit the toggle button you will hide JAN:DEC coulmns UX:AG and also you will hide Rows 45:48 on the YTD INFO sheet.

sorry i wasnt clearer beofre
Thanks
 
Upvote 0
Ok, for the first case use these sheet names OPTIONS PAGE & NEW EQUIP REPAIRS
and for the 2nd case use YTD INFO
 
Upvote 0
Ok, for the first case use these sheet names OPTIONS PAGE & NEW EQUIP REPAIRS
and for the 2nd case use YTD INFO
Im sorry Fluff but could you show the code like it should be?
i understand part of what you are saying but not all.

Thanks
 
Upvote 0
How about
VBA Code:
Private Sub ToggleButton1_Click()
   Dim ws As Worksheet
   
   For Each ws In Worksheets
      Select Case ws.name
         Case "OPTIONS PAGE", "NEW EQUIP REPAIRS"
         Case "YTD INFO"
            ws.Rows("1:3").Hidden = Not ws.Rows("1:3").Hidden
         Case Else
            With ws.Range("U:X, AG:AI").EntireColumn
               .Hidden = Not .Hidden
            End With
      End Select
   Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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