Help with Auto Hiding Col's based on Cell

  • Thread starter Thread starter Frick
  • Start date Start date
F

Frick

I would like to use a macro or formula that will automatically hide a column when a cell in that
column = 0

I have some moving dates which creates some empty col's that I would like to have automatically
hide.

Is this possible?
 
To Hide:
Sub HideColumns()
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet
For Each cell In .Range("C20:K20")
If cell.Value = 0 Then cell.EntireColumn.Hidden = True
Next
End With
Application.ScreenUpdating = True
End Sub

To Unhide:
Sub UnhideColumns()
Application.ScreenUpdating = False
Range("C20:K20").Columns.Hidden = False
Application.ScreenUpdating = True
End Sub

HTH
 
Back
Top