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!
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,059
Office Version
  1. 2013
Platform
  1. Windows
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.
 

GregM

New Member
Joined
Jan 15, 2005
Messages
14
Works like a charm -- thank you very much for your assistance.
Have a great day!
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,059
Office Version
  1. 2013
Platform
  1. Windows
You are welcome. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,201
Messages
5,527,386
Members
409,759
Latest member
KCH

This Week's Hot Topics

Top