You are here:

Excel/VLookup a drop down list

Advertisement


Question
Hi, I am trying to design an order form where my client can select a product code from a drop down list in column A.  I am using VLookups to return the name & description of the product in column B & column C.  However, in column D, I want to give my client a drop down list of quantities he can order but the quantities need to be specific to the product.  I was wondering if it was possible to do this - have a drop down list change depending on the selection in column A.  I have tried a basic VLookup but it returns a value of 0

Thanks


Answer
Example: say you have 2 product codes: XX and YY. For XX, the quantity options are 2 or 4. For YY, the quantity options are 3 or 6 or 9.

Start with a blank Excel sheet. In A1:A2, enter

XX
YY

In C1:C5, enter

XX
XX
YY
YY
YY

In D1:D5, enter

2
4
3
6
9

Select cell F1, and use Data Validation to make it an incell dropdown in which the user can select XX or YY (your Data Validation List Source will be =$A$1:$A$2).

Now select G1 and do another Data Validation. This time, your List Source will be:

=offset($D$1,match($F$1,$C$1:$C$5,0)-1,0,countif($C$1:$C$5,$F$1),1)

Select XX in cell F1, and you'll see that the cell G1 dropdown offers the choices 2 or 4. Select YY in cell F1, and the G1 dropdown offers the choices 3 or 6 or 9.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

All Answers


Answers by Expert:


Ask Experts

Volunteer


Stuart Resnick

Expertise

I can answer questions relating to MS Excel formulas, or to programming with vba (Visual Basic for Applications) in the Excel environment. Please follow the following guidelines: your question should focus on one specific issue you want to learn. It's beyond the scope of this free service for me to create entire projects or complex vba solutions for you from scratch. You should be able to do most of the work yourself, and come here when you need help with a specific point you're stuck on. ALWAYS include a simple, concrete example illustrating what you want to learn. Explain this example in detail in the text of your question (what data is in which cells of which sheets, etc). Be very precise about the results you want, using this sample to make the logic clear. Always keep these examples SIMPLE. Never e.g. use 18 worksheets in your example if using 2 or 3 will do. Never use ranges like AI567:BB865 if using a range like A1:B3 will do. Thanks.

Experience

As a consultant, I've designed Excel tools since the 90s, working for the Federal Reserve Bank, AT&T, and (currently) Gap Inc.

Education/Credentials
My only "education" comes from 2 decades of doing spreadsheet/programming work, with major SF Bay Area corporations such as AT&T, Federal Reserve Bank, and Gap Inc.

©2010 About.com, a part of The New York Times Company. All rights reserved.