View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter Atherton[_29_] Peter Atherton[_29_] is offline
external usenet poster
 
Posts: 1
Default 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