Solved

Dependent Data Validation

Posted on 2013-01-25
6
191 Views
Last Modified: 2013-01-29
Hi,

I have few hundred cities & provinces in one column

Eg: Calgary, AB (City, province)

Next column has 'store names'

eg: Store 1

On the main page, user can type in/choose city via data validation.

Now I want to give the user a chance to select the store location via another data validation list but those that comes in within the user-selected city, province only

Whats the best way to do this without going into VBA? (using formulas only)

One way is, assign stores with same city under a named range

Say I create a named range of "B2:B15" as 'Calgary, AB'

Assuming user chooses city on cell A1 and store on cell A2

on A2, I can do data validation as
= indirect($A1)

However, this would require 100s of named ranges (or 1 for each city)

Any other ways without using macros?
0
Comment
Question by:Shanan212
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38820117
0
 
LVL 23

Expert Comment

by:NBVC
ID: 38820125
If you can list all the cities and corresponding stores grouped together.

e.g..

Calgary, AB......Store1
Calgary, AB......Store2
Calgary, AB......Store3
Toronto, ON.....Store4
Toronto, ON.....Store5
Toronto, ON.....Store6
Toronto, ON.....Store7
Vancouver, BC..Store8
Vancouver, BC..Store9
... etc.  (those are 2 columns)

then call this range something like MyRange

Then in your data validation, use List and enter formula:

=OFFSET(INDEX(MyData,1,2),MATCH($E$2,INDEX(MyData,0,1),0)-1,0,COUNTIF(INDEX(MyData,0,1),$E$2),1)

where E2 is the cell with the City dropdown input.
Copy-of-Test-2.xlsx
0
 
LVL 13

Author Comment

by:Shanan212
ID: 38820210
NB,

The listing part wouldnt work as this data (listing in corresponding order) is not up to me. The user would be entering this and might screw-it up.


ssaqibh,

Please see attached.

Thanks!
Copy-of-Copy-of-dropDownbreakDow.xlsm
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38820240
That method works horizontally. The sub-list has to be entered to the right of the selected item.

If you want to enter the DV items vertically then follow NB_VC's method.
0
 
LVL 23

Accepted Solution

by:
NBVC earned 500 total points
ID: 38820366
If you don't think the users will group the items, then perhaps use a formula to create another list on the side that extracts all the corresponding items, based on the selection.  

So for example in the workbook I attached, in T2 enter formula:

=IFERROR(INDEX($O$2:$O$19,SMALL(IF($N$2:$N$19=$E$2,ROW($N$2:$N$19)-MIN(ROW($N$2:$N$19))+1),ROWS($T$1:$T1))),"")

confirmed with CTRL+SHIFT+ENTER and copied down as far as needed.  * adjust ranges to suit first.

Then in the data validation in F2, use formula:

=OFFSET($T$2,0,0,COUNTIF($T:$T,"?*"),1)
Copy-of-Test-2.xlsx
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 38827852
Thats some next level stuff :)

Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now