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?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,460
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,460
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,991
Messages
5,834,769
Members
430,319
Latest member
Excelhelppll

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top