Help with Auto Hiding Col's based on Cell

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?
 
J

JMay

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top