Toggle Hide Unhide Columns

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Could I please ask if it may be possible to have a button to toggle between the following hide/unhide columns

Hide J:M Unhide O:AB
Then if pressed again
Unhide J:M Hide O:AB
Then if pressed again revert back to the start

many thanks for any help
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Code:
Dim B As Boolean
Sub uhideuhide()
Range("J:M").EntireColumn.Hidden = Not B
Range("O:AB").EntireColumn.Hidden = B
B = Not B
End Sub
 
Upvote 0
Hi all,

Could I please ask if it may be possible to have a button to toggle between the following hide/unhide columns

Hide J:M Unhide O:AB
Then if pressed again
Unhide J:M Hide O:AB
Then if pressed again revert back to the start
Assuming one set of columns is already hidden and the other is not, use this code in your button's click event to produce the toggling effect you want...
Code:
  Columns("J:M").Hidden = Not Columns("J:M").Hidden
  Columns("O:AB").Hidden = Not Columns("O:AB").Hidden
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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