Thread: hiding columns
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default hiding columns

I am using the following code to hide columns, However, it keeps errorring
our on Column 35. If I delete column 35, it still errors out on column 35.
Any suggestions? Thanks.

The error message is as follows:
Run_Time Error 1004

"Unable to set the Hidden property of the Range class"

Sub HideColumns()
Dim X As Integer
Dim EOF As Integer
EOF = 0
EOF = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
For X = 2 To EOF
If UCase(Cells(5, X).Value) = "NO" Then Cells(5, X).EntireColumn.Hidden
= True
Next X
End Sub

Thanks for the help.....
Sub UnHideCols()
Dim X As Integer
Dim EOF As Integer
EOF = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
For X = 2 To EOF
If Cells(5, X).EntireColumn.Hidden = True Then Cells(5,
X).EntireColumn.Hidden = False
Next X
End Sub


--
JT