drop down boxes

Loreng

New Member
Joined
Sep 23, 2004
Messages
31
I have used Data....Validation to create 2 dropdown boxes in adjacent cells (repeated about 50x down the page). The second drop down (col c) is dependant on the selection in the first cell (col b), which I achieved by using the indirect function in the source input (figured that out by reading board archive...Thanks, great tool).

My problem arises when a the user changes, or deletes the first cell. The old value remains in the second drop down.

How can I get the second cell to erase when the first is changed?

Is there an event trigger in VBA, that says if any cell in a row changes, then delete the cell 1 row to the right?
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,459
Let's say you have your dropdowns in cell A1 and B1, and you want to make B1 blank.

1. Press Alt-F11 to bring up VBA
2. In the left-pane, double-click the sheet to which you want to attach this
3. Paste this into the right pane:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [b1].ClearContents
End Sub
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,459
If you want to adapt it for the whole column, then:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Target.Offset(0,1).ClearContents
End Sub
 

Loreng

New Member
Joined
Sep 23, 2004
Messages
31
that is perfect...thanks for both of your help

appreciate the fast response!
 

Loreng

New Member
Joined
Sep 23, 2004
Messages
31
arrrgh...more help w/ VBA code

What if, instead of the entire column, I only want to apply the code to a range B19-B105?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = B19:B105 Then Target.Offset(0,1).ClearContents
End Sub


the above is what I want it to do, but does not work
 

Watch MrExcel Video

Forum statistics

Threads
1,118,055
Messages
5,569,948
Members
412,299
Latest member
agentless
Top