Hiding a column if a cell has an X

  • Thread starter Thread starter tr2yhb
  • Start date Start date
T

tr2yhb

I have two sheets in my file.

Here is what I need to do:

If a box in sheet1 has an "x" I want a column (sometimes 2 or 3
columns) on sheet2 to automatically hide.

Thank you for your help.
 
What is a "box" and how does the "x" get into that box?

Assume your subject is correct and you mean "cell", you could use some
event code to do the job.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$2" And Target.Value = "x" Then
Sheets("Sheet2").Range("A:A").EntireColumn.Hidden = True
End If
stoppit:
Application.EnableEvents = True
End Sub


Gord
 
Back
Top