Back

About MrExcel
Consulting Services
Learn Excel Resources
Challenge of the Month
MrExcel Seminars

Message Board

MrExcel Store
Podcast
Search
Contact
Home

 

 
One good use of Data Validation comes when there's a need to "link" two or more comboboxes, making them, dependant.

For example, John asks "I have a list of countries (USA, Australia, England), and a list of cities. How can I make than when the user selects USA in one cell, in the other one appear only cities from USA (New York, Los Angeles), and also for Australia (Camberra, Perth), etc. ?"

The first thing that needs to be done is name the lists. Select the countries, without the title, and name it COUNTRIES. Next, select all cities (Again without titles) from USA and name it USA. Continue this process for every country.

Now, let's assume that the first list appears in A1. Go to Data, Validation, Select List, and in "Source" put

=COUNTRIES.

Make sure that "In-cell dropdown" is checked.

Now, if the second list appears in B1, go to Data, Validation, again Select List, and in "Source" put

=INDIRECT(A1)

If Excel returns an error, don't worry, you don't have anything selected in A1. To test it, select a country in A1, and now, when you click in B1 you should see only the cities from that country.

Addition. Ian Narbeth asked to remind that Defined Names can't include spaces, so, to enter, Great Britain, you would have to put it like "Great_Britain" or "GreatBritain". Thanks for that.

By Juan Pablo Gonzalez on 26-Jan-2002

MrExcel.com Consulting can be hired to implement this concept, or many other cool applications, with your data.

MrExcel.com provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.

 

Excel is a registered trademark of the Microsoft® Corporation.

All contents Copyright 1998-2008 by MrExcel Consulting.