+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Alternative to if statement ?

  1. #1
    Registered User
    Join Date
    11-10-2009
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Alternative to if statement ?

    I need a formula that gives the following result

    If I type a colour into the first column, a price appears in the second column, depending on the colour I type in.

    I have got this working up to a point using the if statement below but have exceeded nesting levels.

    =IF(ISNUMBER(SEARCH("orange",A2)),38.36,IF(ISNUMBER(SEARCH("black",A2)),23.38,IF(ISNUMBER(SEARCH("blue",A2)),23.21,IF(ISNUMBER(SEARCH("white",A2)),31.5,IF(ISNUMBER(SEARCH("brown",A2)),36.28,IF(ISNUMBER(SEARCH("green",A2)),26.89))))))

    Any help much appreciated.

    Tommo

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,467

    Re: Alternative to if statement ?

    Try using a VLOOKUP instead.

    You will need a table of colours and values.

    Edit: hold that thought.

    Does A2 contain other information besides colour?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Alternative to if statement ?

    I would suggest you list your colours in a column somewhere with the respective value in the adjacent cells.... order in terms of colour preference (first to be looked for listed first) ... let's assume your list is in AA1:AB10 then something like:

    =INDEX(AB1:AB10,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(AA1:AA10,A2)),0),0))

  4. #4
    Registered User
    Join Date
    11-10-2009
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Alternative to if statement ?

    Thanks for the reply but that is not quite what I am looking for.

    I need to input the colour manually and have the price go in automatically.

    ie if I type orange in column A 20.00 appears in column B

    blue = 30.00
    brown = 40.00
    green = 50.00

    etc

    Tommo

    Edit: To Andy Pope. No, the only information in the A column is the colour

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,467

    Re: Alternative to if statement ?

    =VLOOKUP(A1,{"Blue",30;"Brown",40;"Green",50},2,FALSE)

    Although as DO and I said it would be better to create a table of colours and values.
    So if the table was in D1:E3 the formula would be.

    =VLOOKUP(A1,$D$1:$E$3,2,FALSE)

+ 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