Hide columns based on cell value

  • Thread starter Thread starter bill.shut
  • Start date Start date
B

bill.shut

I have a IF formula in a cells H4:M4 that says HIDE or UNHIDE based on
a condition in another cell. I want to hide the column based on the
HIDE/UNHIDE value of the formula. I want to be able to change which
columns are hidden based on the result of the IF formula, as it changes
depending on the condition in another cell. I tried to follow some of
the macros in the forum, but got lost as most refer to hiding rows.

Thanks, Bill
 
One way:

Put this in your worksheet code module (right-click the worksheet tab
and choose View Code):

Private Sub Worksheet_Calculate()
Dim rCell As Range
For Each rCell In Range("H4:M4")
rCell.EntireColumn.Hidden = (rCell.Value = "HIDE")
Next rCell
End Sub
 

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

Similar Threads

Hide column with locked cells 2
Expand and collapse rows 7
Help needed 0
checkbox problem 22
Excel VBA 1
Hide columns based on row values 2
Hide Unhide Button 4
Conditional formatting based on formula cell 6

Back
Top