Data validation is a great way to keep your users informed about possible values in a cell and guide them to select something appropriate. As part of the spreadcheats series, in this post we will discuss 2 advanced data validation techniques that can help you when you are modeling a complex worksheet.
Problem 1: You have 2 lists of possible values and you want a way to switch between both
PS: Many thanks to Alex who proposed this idea and solution through e-mail.
You have a cell where user can enter any value from 2 lists. But you don’t want to overload the in-cell drop down list with tons of values, and rather prefer a simpler approach like this:

Solution: Use an IF() formula in validation criteria
The solution is to use an if() formula to determine which one of the two ranges should be used to validate cell contents.
- Select the cell where you want to have this type of validation
- Go to menu > data > validation
- In the criteria area, select “allow” as “list”
- In the source area, specify a formula like this:
=IF($B$7="Full List",Full-list-range,Partial-list-range)
That is all, you now have a data validation list that can change its source based on user preference.
Problem 2 : You would like to change a list’s values based on what is selected in another list
PS: Many thanks to Catherine for asking this question through email
You have a status tracking spreadsheet where each employee enters the status for each of the projects they are working on. They enter the status by first selecting the department and then selecting a project (from that department).
So how do you do this in Excel?
Solution: Use OFFSET and MATCH to determine which range to use
Remember the offset() and match() formulas we discussed in the last spreadcheats? Assuming the list of projects for each department is in a range B10:C22 with column B having the department name and column C having the project name and the list is sorted on column B, we can use offset() and match() combination along with countif (ahem!) to determine which range to use for project cell drop-down.
- For the department cell, we can use simple list validation with values as “Marketing, Ops, Sales, IT”
- For project cell, go to data validation (menu > data > validation) and specify a formula like this:
=OFFSET(C9,MATCH($B$6,$B$10:$B$22,0),0,COUNTIF(B10:B22,$B$6),1) - What is above formula doing? It is fetching a sub-range from the by finding where the first entry for the selected department is, returning x number of rows from that point, where x = no. of projects in that department.
That is all. You now have a list drop-down that changes values based on what is selected in an earlier cell.
Still having doubts?
Feel free to download this example workbook containing a tutorial on Advanced Data Validation in Excel and poke around to learn.














13 Responses to “Data Validation using an Unsorted column with Duplicate Entries as a Source List”
Pivot Table will involve manual intervention; hence I prefer to use the 'countif remove duplicate trick' along with 'text sorting formula trick; then using the offset with len to name the final range for validation.
if using the pivot table, set the sort to Ascending, so the list in the validation cell comes back alphabetically.
Hui: Brillant neat idea.
Vipul: I am intrigued by what you are saying. Please is it possible to show us how it can be done, because as u said Hui's method requires user intervention.
Thks to PHD and all
K
Table names dont work directly inside Data validation.
You will have to define a name and point it to the table name and then use the name inside validation
Eg MyClient : Refers to :=Table1[Client]
And then in the list validation say = MyClient
Kieranz,
Pls download the sample here http://cid-e98339d969073094.skydrive.live.com/self.aspx/.Public/data-validation-unsorted-list-example.xls
Off course there are many other ways of doing the same and integrating the formulae in multiple columns into one.
Pls refer to column FGHI in that file. Cell G4 is where my validation is.
Vipul:
Many thks, will study it latter.
Rgds
K
[...] to chandoo for the idea of getting unique list using Pivot tables. What we do is that create a pivot table [...]
@Vipul:
Thanks, that was awesome! 🙂
@Playercharlie Happy to hear that 🙂
Great contribution, Hui. Solved a problem of many years!
Thanks to you, A LOT
Hi Hui,
Greeting
hope you are doing well.
I'm interested to send you a private vba excel file which i need to show detail of pivot in new workbook instead of showing in same workbook as new sheet.
Please contact me on muhammed.ye@gmail.com
Best Regards