Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel question 1

Status
Not open for further replies.

msnook

Technical User
Jul 6, 2007
41
US
Sorry I am having a major brain fart this morning. I have the code listed below on Sheet 1 of my spreadsheet. If it finds one of three values it unhides column E and if it doesn't find those values it hides the column. It works fine checking D3 but I need it to run through and check D3-D100 and take the same action if any one of those cells contain the stated variables. Any help would be greatly appreciated.
------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$D$3" Then
If Target.Value = "Check" Then
Columns("E").EntireColumn.Hidden = False
Else
If Target.Value = "Pay Pal" Then
Columns("E").EntireColumn.Hidden = False
Else
If Target.Value = "Money Order" Then
Columns("E").EntireColumn.Hidden = False
Else
Columns("E").EntireColumn.Hidden = True
End If
End If
End If
End If

End Sub
 
What about this ?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("D3:D100")) Is Nothing) Then
Columns("E").EntireColumn.Hidden = (Target.Value <> "Check" And Target.Value <> "Pay Pal" And Target.Value <> "Money Order")
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, that works. The only tweak that I would need to make would be that if any one of the entries in column is one of the triggers the column would stay open no matter what is picked after that one. The new code will close up column E if you pick one of the choices that is not a trigger no matter what was the pick right before that one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top