Creating a drop down in data validation using indirect

mrichard

New Member
Joined
Mar 23, 2020
Messages
29
Office Version
  1. 2016
Platform
  1. Windows
I am trying to do a drop down list using data validation. My scenario:

Lets say I have a drop down list of the State of MD and CA and I want to select one of these states. I will have another drop down list that has a named range that lists the cities for each state using the indirect formula.

I have this part working. So when I select a State either MD or CA in one cell (drop down list) I will only the see the cities from the state selected in another drop down.
My issue is when I change the State from lets say MD to CA the city drop down still shows the city from MD until I change the city in the drop down to the CA city list. My goal is that when I change from one state to another I want the city drop down cell to be blank until I actually select the new city.

I hope I have explained this properly.
Any help would be appreciated.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This is a dependent drop down issue.
First, create your state drop down in, say, C2.

Then, after you have your cities for MD and CA in, say, columns H and I, respectively (or elsewhere), select those.
From the formula tab, select Define Name, then Create From Selection, and reference only the TOP.

Then, in the cell, say D2, create drop down for the cities list and the reference would be: =INDIRECT(C2)

Does that help?

Sorry about not focusing on the "goal"...which can't be done without VBA as Fluff points out.
 
Last edited:
Upvote 0
My goal is that when I change from one state to another I want the city drop down cell to be blank until I actually select the new city.
You would need VBA for that. Is that okay?
 
Upvote 0
This is a dependent drop down issue.
First, create your state drop down in, say, C2.

Then, after you have your cities for MD and CA in, say, columns H and I, respectively (or elsewhere), select those.
From the formula tab, select Define Name, then Create From Selection, and reference only the TOP.

Then, in the cell, say D2, create drop down for the cities list and the reference would be: =INDIRECT(C2)

Does that help?

Sorry about not focusing on the "goal"...which can't be done without VBA as Fluff points out.
Thanks.
 
Upvote 0
Where are the state & city drop downs?
 
Upvote 0
Where are the state & city drop downs?
Maybe this will help:
1619630902689.png
 
Upvote 0
Ok, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "I5" Then
      Range("K5").Value = ""
   End If
End Sub
This needs to go in the sheet module for that sheet.
 
Upvote 0
Solution
Ok, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "I5" Then
      Range("K5").Value = ""
   End If
End Sub
This needs to go in the sheet module for that sheet.
I will give it a try. Stay tuned

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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
Back
Top