Hiding columns based on row 4 criteria

P

Pierre

Looking for a macro to hide any columns from columns "W" through "HE"
if the cell in that column in row 4 is equal to zero (a formula exists
in the row 4 cell.)

Also, I surmise, if the macro includes the word "true", I can change
that to "false", and get a macro to open all the closed columns?

Thanks for any suggestions.

Pierre
 
M

Mike H

Hi,

Right click the sheet tab, view code and paste this in and run it. Changing
True to false unhides

Sub mariner()
Set myrange = Range("W4:HE4")
For Each c In myrange
If Not IsEmpty(c) And c.Value = 0 Then
c.EntireColumn.Hidden = True
End If
Next
End Sub

Mike
 

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