Creating a drop down in data validation using indirect

mrichard

New Member
Joined
Mar 23, 2020
Messages
21
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

kweaver

Well-known Member
Joined
May 8, 2018
Messages
2,065
Office Version
  1. 365
  2. 2010
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:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,112
Office Version
  1. 365
Platform
  1. Windows
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?
 

mrichard

New Member
Joined
Mar 23, 2020
Messages
21
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,112
Office Version
  1. 365
Platform
  1. Windows
Where are the state & city drop downs?
 

mrichard

New Member
Joined
Mar 23, 2020
Messages
21
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

Where are the state & city drop downs?
Maybe this will help:
1619630902689.png
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,112
Office Version
  1. 365
Platform
  1. Windows
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.
 
Solution

mrichard

New Member
Joined
Mar 23, 2020
Messages
21
Office Version
  1. 2016
Platform
  1. Windows
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
 

Forum statistics

Threads
1,136,735
Messages
5,677,462
Members
419,693
Latest member
divtjd

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