View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default hide and show columns using one control button

I just spent 35 minutes looking for that other post <vbg.

I was going to add a "see your thread in...", but you had already posted, so I
didn't.



Tom Ogilvy wrote:

See my answer to your other post in Misc

<just joking

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
Hey!

Those blank lines came from the paste--not the original post.



Tom Ogilvy wrote:

Not quite as simple as mine although it is essentially identical. I

guess I
need to put a lot of blank lines in my code. It doesn't make any
difference it hides more columns than F and I?

--
Regards,
Tom Ogilvy

"dreamkeeper" wrote in message
oups.com...
someone from another group gave me this and it works great and very
easy to interpret.

thanks again!
Tina

Option Explicit
Sub HideUnhide()


Dim myBTN As Button
Dim RngToHide As Range


With ActiveSheet
Set myBTN = .Buttons(Application.Caller)
Set RngToHide = .Range("F:I")
End With


RngToHide.EntireColumn.Hidden = Not (RngToHide.Columns(1).Hidden)


If RngToHide.Columns(1).Hidden Then
myBTN.Caption = "Show This Year"
Else
myBTN.Caption = "Hide this Year"
End If
End Sub


--

Dave Peterson


--

Dave Peterson