Hiding a column if a cell has an X

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.
 
G

Gord Dibben

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
 

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