View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
dreamkeeper dreamkeeper is offline
external usenet poster
 
Posts: 14
Default hide and show columns using one control button

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