+ Reply to Thread
Results 1 to 4 of 4

Create a drop down list and use Lookup to get corresponding items

  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2007
    Posts
    8

    Create a drop down list and use Lookup to get corresponding items

    I am making a spreadsheet for food and calories, On sheet one i have a meal tracker, I want to have a drop down list in colum 1 that references the food list on sheet 2, column A=food, column B=Protien, column C=Carbs, column D=fat. The values from Sheet 2 columns B-D would then be inserted into Sheet A in the respective slots. I have fiddled with vlookup and tried numerous things but I can't seem to figure this out. Any help would be appreciated!
    Last edited by cecilj; 11-16-2009 at 11:13 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Lookup

    First, name the Food Range (single column range) in Sheet2 through Insert|Name|Define... call it Food...

    Then in Sheet 1, where you want the dropdown, go to Data|Validation and select List... enter =Food

    then, assuming this is in A2,

    Then in B2, =Vlookup($A2,Sheet2!$A$1:$D$100,Columns($A$1:B$1),0)

    where Sheet2 A1:D100 contains your food table...

    copied across to get next values in matching row.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-12-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Create a drop down list and use Lookup to get corresponding items

    Worked great! the only other thing that I could use a fix for is when i don't have any values in the food list on sheet 1 I get an #N/A in the protein, carb, fat columns. Is there any way to rectify this?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Create a drop down list and use Lookup to get corresponding items

    Try using this formula instead:

    =IF(Isnumber(Match($A2,Sheet2!$A$1:$A$100,0)),Vlookup($A2,Sheet2!$A$1:$D$100,Columns($A$1:B$1),0),"")

    adjusting ranges and references to suit. (this will return a null if match not found)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1