+ Reply to Thread
Results 1 to 6 of 6

An IF function with 4 outcomes

  1. #1
    Registered User
    Join Date
    05-02-2013
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2011, Mac
    Posts
    19

    Talking An IF function with 4 outcomes

    Hi guys, I am sort of stuck with an IF function so I need your help.

    My column D is filled with different three-digit numbers that don't go in any particular order.

    So if the value of D is 235 or 244 or 307 - I need the function to write A (there is actually much more numbers that go into the condition, but you get the point)
    If the value of D is 330 or 331 or 333 or 340 or 341 or 379 or 380 or 709 or 714 - I need the function to write B
    If the value of D is 342 or 370 or 375 or 455 - I need the function to write C
    And if the value of D is any other number, I want the function to leave a blank space.

    So that's it, I hope I explained it right. Let me know if you need any additional info.

    Thanks! :D

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: An IF function with 4 outcomes

    Create a 2 column table like this:

    235...A
    244...A
    307...A
    330...B
    333...B
    340...B
    341...B
    379...B
    380...B
    709...B
    714...B
    342...C
    370...C
    375...C
    455...C

    Assume that table is in the range A2:B16

    D2 = some number like 709

    Enter this formula E2:

    =IFERROR(VLOOKUP(D2,A$2:B$16,2,0),"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Doha, State of Qatar
    MS-Off Ver
    excel 2003, 2007, 2010, 2016
    Posts
    124

    Re: An IF function with 4 outcomes

    =if(or(d1=235,d1=244,d1=307),"a",if(or(d1=330,d1=331,d1=333,d1=340,d1=341,d1=379,d1=380,d1=709,d1=714),"b",if(or(d1=342,d1=370,d1=375,d1=455),"c","unmatched")))

    try this its done....!
    Regards,
    abdul

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: An IF function with 4 outcomes

    Abdul, Biff's suggestion is more flexable, scalable and easietr to understand If the OP were to add another range (d), or add extra numbers to their existing ranges, the table is easier to adapt.

    Your suggestion works just as well though
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    05-02-2013
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2011, Mac
    Posts
    19

    Re: An IF function with 4 outcomes

    Worked like a charm! Thank you abubaniyan!

  6. #6
    Forum Contributor
    Join Date
    12-14-2012
    Location
    Doha, State of Qatar
    MS-Off Ver
    excel 2003, 2007, 2010, 2016
    Posts
    124

    Re: An IF function with 4 outcomes

    @lija:- my pleasure.....!

+ 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