ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Hide/Show (https://www.excelbanter.com/excel-programming/289621-toggle-hide-show.html)

Peter Atherton[_29_]

Toggle Hide/Show
 

-----Original Message-----
Greetings,
I would like button that the first time its clicked, will

hide columns C:G and when clicked the next time will show
the same columns. I can write the code to separately hide
or show but I dont know how to combine them to toggle when
the button is clicked.
All help is greatly appreciated!
Alan
.

Alan

This will do. Right click the sheet tab and select View
Code. Paste the following macro then assign it to a button.

Sub ToggleHidden()
Dim rng As Range
Set rng = Range(Cells(1, 3), Cells(1, 7))
rng.EntireColumn.Hidden = rng.EntireColumn.Hidden = False

End Sub

Regards
Peter


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com