Macro for Show/Hide Column

A

Andy

Hi

I am trying to write a Macro to Toggle Show/Hide column D

Anybody able to help?

with thanks...Andy
 
T

tjtjjtjt

Here's a basic macro that will do it:

Sub HideColD()
Columns("D:D").Select
If Selection.EntireColumn.Hidden = False Then
Selection.EntireColumn.Hidden = True
Else
Selection.EntireColumn.Hidden = False
End If
Range("D1").Select
End Sub


tj
 
B

Bob Phillips

Simpler

With Columns("D:D")
.Hidden = Not .Hidden
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Don Guillett

or

Sub togglehide()
columns("d").Entirecolumn.Hidden = True = Not _
columns("d").Entirecolumn.Hidden = True
End Sub
 
A

Andy

worked well. chose this one.

tjtjjtjt said:
Here's a basic macro that will do it:

Sub HideColD()
Columns("D:D").Select
If Selection.EntireColumn.Hidden = False Then
Selection.EntireColumn.Hidden = True
Else
Selection.EntireColumn.Hidden = False
End If
Range("D1").Select
End Sub


tj
 
Top