S
smduello
I found a Macro, but I am having trouble modifying it to auto-hide the
column if a certain cell is empty. ie. I have blank columns that
serve as spaces between the next grouping of data and its hiding
everything. Basically, I want to say hide if a certain cell has a 0
(zero) in it. Any ideas?
Option Explicit
Sub hideCols()
Dim iCol As Long
With ActiveSheet
For iCol = 1 To .Cells(1, .Columns.Count).End(xlToLeft).Column
If Application.CountA( _
.Cells(2, iCol).Resize(.Rows.Count - 1)) = 0 Then
.Columns(iCol).Hidden = True
Else
.Columns(iCol).Hidden = False
End If
Next iCol
End With
column if a certain cell is empty. ie. I have blank columns that
serve as spaces between the next grouping of data and its hiding
everything. Basically, I want to say hide if a certain cell has a 0
(zero) in it. Any ideas?
Option Explicit
Sub hideCols()
Dim iCol As Long
With ActiveSheet
For iCol = 1 To .Cells(1, .Columns.Count).End(xlToLeft).Column
If Application.CountA( _
.Cells(2, iCol).Resize(.Rows.Count - 1)) = 0 Then
.Columns(iCol).Hidden = True
Else
.Columns(iCol).Hidden = False
End If
Next iCol
End With