lbstateguy
New Member
- Joined
- May 26, 2011
- Messages
- 3
Hi there,
I have a spreadsheet where I want to hide/show empty columns. Problem is that I have everyother column hidden already. I wrote a code that works great, but when I run a macro that adds columns (hidden and showing), the new macro does not work. Can anyone help?
This is the code I have
I have a spreadsheet where I want to hide/show empty columns. Problem is that I have everyother column hidden already. I wrote a code that works great, but when I run a macro that adds columns (hidden and showing), the new macro does not work. Can anyone help?
This is the code I have
Code:
Sub HideCol()
Dim cl As Range, rTest As Range
Set rTest = Range("F75:AH75", Range("F75:AH75").End(xlToRight))
For Each cl In rTest
If Not cl.Value > 0 Then
cl.EntireColumn.Hidden = True
End If
Next cl
End Sub
Sub UnHideCols()
Dim cl As Range
For Each cl In Sheets("Budget").Range("F75, H75, J75, L75, N75, P75, R75, T75, V75, X75, Z75, AB75, AD75, AF75, AH75, AJ75, AK75, AL75, AM75")
If UCase(cl) = "0" Then
cl.EntireColumn.Hidden = False
Else: cl.EntireColumn.Hidden = False
End If
Next cl
End Sub
[endcode]