Buttons to HIDE / UNHIDE columns

GregM

New Member
Joined
Jan 15, 2005
Messages
14
Hello friends. I have put together the following by reading several similar threads. I am putting two buttons at the top of a spreadsheet, one to display the first group and hide the second and vice-versa. If possible, I guess it'd be better to use one button to toggle these changes. I figured out how to insert the code and attach it to the button, I just need help in writing this code EXACTLY as it should be to put it in a module.

Two buttons: 1) Select columns("O:U") .Hidden = False, Select columns("V:AK") .Hidden = True
2) Select columns("O:U") .Hidden = True, Select columns("V:AK") .Hidden = False

Thanks to all!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
GregM,


Here is one way that will toggle.

Code:
Sub Toggle_Cols()
Range("O1:U1").EntireColumn.Hidden = Range("V1:AK1").EntireColumn.Hidden
Range("V1:AK1").EntireColumn.Hidden = Not Range("O1:U1").EntireColumn.Hidden
End Sub

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,215,577
Messages
6,125,637
Members
449,242
Latest member
Mari_mariou

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