Toggle Button in Excel

W

William

I am using Office 2007/Vista. I have created a toggle button that I would
like to use to expand 3 hidden columns (D, E, & F) on the first click. I
would then like for it to rehide the columns on the 2nd click, and from that
point on just alternate unhiding and hiding the columns on each click. I
have the first part down sucessfully below, which exapands the columns on the
first click:

Private Sub ToggleButton1_Click()
Columns("D:F").Select
Selection.EntireColumn.Hidden = False
End Sub

I am sure that to rehide the columns that you change the False to True, but
I can not figure out how to make this the second click of the toggle button.
How can I do this? Thanks!!!
 
L

Leon

Sheet1.Columns("E:F").EntireColumn.Hidden = _
Not Sheet1.Columns("E:F").EntireColumn.Hidden
 
C

Clif McIrvin

Leon said:
Sheet1.Columns("E:F").EntireColumn.Hidden = _
Not Sheet1.Columns("E:F").EntireColumn.Hidden

or

With ActiveSheet
.Columns("E:F").EntireColumn.Hidden = _
Not .Columns("E:F").EntireColumn.Hidden
End With
 
W

William

Thank you very much Clif. Works great !!!!

Clif McIrvin said:
or

With ActiveSheet
.Columns("E:F").EntireColumn.Hidden = _
Not .Columns("E:F").EntireColumn.Hidden
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top