View Single Post
  #7   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

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