+ Reply to Thread
Results 1 to 5 of 5

Thread: How to add several IF-conditions in one cell?

  1. #1
    Registered User
    Join Date
    01-22-2012
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    2

    How to add several IF-conditions in one cell?

    Column A has values Green, Red, Blue.
    Column B has values Circle, Triangle, Square.
    Column C has values 1, 2, 3.

    What I wish to accomplish is that Column C has a value based on A and B relationship.

    Example:
    If Column A=Green and B=Circle, then C=1
    If Column A=Red and B=Triangle, then C=2
    If Column A=Blue and B=Square, then C=3
    etc

    If A and B have any other combinations, display no value.

    I can make work if I use:
    =IF(AND(A:A="Green";B:B="Circle");1)



    BUT how do I add all conditions in one cell so whatever combination I need is automatically created?

    I dont know what to put between two or more IF-clauses.
    Semicolon is wrong:
    =IF(AND(A:A="Green";B:B="Circle");1);IF(AND(A:A="Red";B:B="Triangle");2)

    Any help is very much appreciated.

    Cheers
    Mafishas

  2. #2
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,952

    Re: How to add several IF-conditions in one cell?

    You can't join IF statements quite like that.

    You can do:

    =IF(AND(A1="Green";B1="Circle");1;IF(AND(A1="Red";B1="Triangle");2;""))

    Depending on how many combinations you have you might end with quite a long-winded formula, so it might be worth looking at other ways to get what you're after.

  3. #3
    Registered User
    Join Date
    12-25-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to add several IF-conditions in one cell?

    I could be wrong Mafishas but if you start with an AND this should solve it.
    I'll investigate.

  4. #4
    Registered User
    Join Date
    12-25-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How to add several IF-conditions in one cell?

    I used a combination of concatenate and vlookup.
    Hope it helps. Stay healthy.

    Book1.xlsx

  5. #5
    Registered User
    Join Date
    01-22-2012
    Location
    Tallinn, Estonia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: How to add several IF-conditions in one cell?

    Andrew, I tried your way and all is fine and dandy.
    But true, the string is going to be long if there are many variables. Luckily I have <10 and will try it like that for now.
    Also, healthyanalyst, will dwell into how you made it happen.

    Thanks a bunch.

+ 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.2.0