PEC-Memphis
New Member
- Joined
- Apr 15, 2009
- Messages
- 19
I posted a question a week or so ago, where a VBA would run on one worksheet but not another. It seems that I didn't understand the problem. After goobing around some more, the problem is related to using the validation pull-down. Here is the VBA:
Seems simple enough?
If I manually enter "DBS" in cell D5, col "J" is unhidden, if I manually enter anything else in D5 col "J" is hidden; ie. the VBS works as intended.
Here's the problem: If I enter "DBS" using the validation dropdown it doesn't work, ie col "J" remains in the current state of "hidden-ness", unless I put the cursor in the formula bar after "DBS" and click on the check mark or hit enter.
I need for the users to be able to use the drop down list because the value in D5 also is used with VLOOKUP function to enter data in other cells from a library of data.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("D5") <> "DBS" Then
Columns("J").EntireColumn.Hidden = True
Else
Columns("J").EntireColumn.Hidden = False
End If
End Sub
If Range("D5") <> "DBS" Then
Columns("J").EntireColumn.Hidden = True
Else
Columns("J").EntireColumn.Hidden = False
End If
End Sub
Seems simple enough?
If I manually enter "DBS" in cell D5, col "J" is unhidden, if I manually enter anything else in D5 col "J" is hidden; ie. the VBS works as intended.
Here's the problem: If I enter "DBS" using the validation dropdown it doesn't work, ie col "J" remains in the current state of "hidden-ness", unless I put the cursor in the formula bar after "DBS" and click on the check mark or hit enter.
I need for the users to be able to use the drop down list because the value in D5 also is used with VLOOKUP function to enter data in other cells from a library of data.
Last edited: