+ Reply to Thread
Results 1 to 9 of 9

IF statements from a long list?

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    IF statements from a long list?

    I'm a very green Excel user. I am trying to create an options invoice that will allow drop down lists for options we offer. That part I've got. But when I have longer lists (the one that I'm hung up on is ten items long), the IF statements (for the price cell) stop working. It seems they stop working after eight. Here is what I had:

    =E24*IF(G24="Standard",0,(IF(G24="Kitchen Faucet #1",160,IF(G24="Kitchen Faucet #2",260,IF(G24="Kitchen Faucet #3",210,IF(G24="Kitchen Faucet #4",170,IF(G24="Kitchen Faucet #5",270,IF(G24="Kitchen Faucet #6",300,IF(G24="Kitchen Faucet #7",240,IF(G24="Kitchen Faucet #8",350,IF(G24="Kitchen Faucet #9",390,)))))))))))

    Note: E24 is the quantity

    Some poking around on Google indicates that nested IF statements are limited to eight. If that is true, how would I get this functionality for longer lists? Is there a better/easier method I should be using?



    More background: In case it is not obvious, I want to have a column for quantity that is manually input, then a column for options that would allow selection from a pre-determined drop down list, then a column that would indicate the price based on what is selected from the drop down list and the quantity selected.
    Last edited by jkendrick; 10-25-2011 at 05:28 PM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: IF statements from a long list?

    Place your pricing into a table somewhere in your workbook out of sight, on another sheet would be a good place. Name it PricingTable. In the first column, place all of your labels such as Standard, Kitchen Faucet, etc. In the second column, put all of your prices. Then use this formula
    Please Login or Register  to view this content.
    Last edited by tlafferty; 10-25-2011 at 04:35 PM. Reason: Further explanation
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: IF statements from a long list?

    As per tlafferty's description:
    Attached Files Attached Files
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  4. #4
    Registered User
    Join Date
    10-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IF statements from a long list?

    Thanks that seems to have worked, but now the price is displayed below the item in the drop down as well. Is there any way to eliminate that?

    ETA: I just saw ConneXionLost's response. Since his example doesn't do that, I must have done something wrong. I'll poke around more in that example to see what is different. Thanks!
    Last edited by jkendrick; 10-25-2011 at 04:50 PM.

  5. #5
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: IF statements from a long list?

    ConneXionLost - Slick! I've wondered sometimes how to make a table dynamic via formula so users don't have to be aware of how to expand the range - sweet!

  6. #6
    Registered User
    Join Date
    10-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IF statements from a long list?

    Okay still a bit stymied. I have the product list on sheet 3 with the list occupying cells A1-A10. I have named these cells "KitchenSpray." The prices are to the immediate right of the products in cells B1-B10. These cells have not been named or anything. Inserting this formula into the price cell on sheet one:

    =E24*VLOOKUP(G24,KitchenSpray,2, FALSE)

    I get a result of #REF!

    It worked when I named the whole thing--product name and price--"KitchenSpray" but then the drop down also displayed the price, which I hope to avoid.

  7. #7
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: IF statements from a long list?

    Hi there - here's how VLOOKUP works:
    the first argument after the opening parenthesis ( -in this case G24- is the value you want to lookup or find a match for in your pricing table. So we're entering G24 in the formula, which instructs Excel to go searching for whatever value you entered into that cell.

    The second argument in the formula is the range to search through to find a match. VLOOKUP always looks vertically through the first column in a range you tell it to examine, in this case the first column of the KitchenSpray where you should have entered your fawcet makes and models.

    The third argument tells it what column to pull from, in this case column 2. Your named range KitchenSpray needs to be 2 columns wide, not 1.

    The last argument instructs Excel what kind of match to use (FALSE = exact, TRUE = close).

    To avoid seeing the prices, name the first column of your KitchenSpray table something like Options, and use the formula
    Please Login or Register  to view this content.
    in your data validation.
    Last edited by tlafferty; 10-25-2011 at 05:19 PM. Reason: Further explanation.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: IF statements from a long list?

    Another way, but not so flexible as a lookup table:

    =E24*( (G24="Standard")*0 +(G24="Kitchen Faucet #1")*160+(G24="Kitchen Faucet #2")*260+(G24="Kitchen Faucet #3")*210+(G24="Kitchen Faucet #4")*170+(G24="Kitchen Faucet #5")*270+(G24="Kitchen Faucet #6")*300+(G24="Kitchen Faucet #7")*240+(G24="Kitchen Faucet #8")*350+(G24="Kitchen Faucet #9")*390)


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  9. #9
    Registered User
    Join Date
    10-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IF statements from a long list?

    Thank you so much! I get it and it works. Problem (and thread) solved!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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