+ Reply to Thread
Results 1 to 11 of 11

IF function with 3 options

Hybrid View

Airka1129 IF function with 3 options 06-11-2014, 10:04 AM
Jonmo1 Re: IF function with 3 options 06-11-2014, 10:09 AM
AlKey Re: IF function with 3 options 06-11-2014, 10:09 AM
Airka1129 Re: IF function with 3 options 06-11-2014, 10:14 AM
Jonmo1 Re: IF function with 3 options 06-11-2014, 10:21 AM
martindwilson Re: IF function with 3 options 06-11-2014, 10:17 AM
Jonmo1 Re: IF function with 3 options 06-11-2014, 10:18 AM
AlKey Re: IF function with 3 options 06-11-2014, 10:19 AM
Airka1129 Re: IF function with 3 options 06-11-2014, 10:57 AM
martindwilson Re: IF function with 3 options 06-11-2014, 11:13 AM
Airka1129 Re: IF function with 3 options 06-11-2014, 11:16 AM
  1. #1
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    IF function with 3 options

    I am trying to write a formula with the following:
    -if I9=0, then write 0
    -if I9=501, then write 1
    -if I9=502, then write 2

    What would be the best way to write this formula? I am sure this should be pretty basic, but everything I try comes up with an error.

    Thanks!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF function with 3 options

    You could do

    =IFERROR(MATCH(I9,{0,501,502},0)-1,"")

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: IF function with 3 options

    Try this one

    =LOOKUP(I9,{0,501,502},{0,1,2})
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    Re: IF function with 3 options

    I tried both of those formulas and it comes up #N/A. I know it shouldn't be this hard and I am starting to feel like an idiot!

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF function with 3 options

    Quote Originally Posted by Airka1129 View Post
    I tried both of those formulas and it comes up #N/A.
    It's not possible for the formula I posted to return #N/A, that's the purpose of the IFERROR funciton.

    What version of XL are you using?
    Is it possible for the cell to contain values other than 0 501 or 502?
    Perhaps I9 isn't really a number, but a "Number stored as Text"
    What does this return?
    =ISNUMBER(I9)


    Can you post a sample book?


    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF function with 3 options

    if I9 can only contain 0,501,502
    then
    =MOD(I9,500)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: IF function with 3 options

    Quote Originally Posted by martindwilson View Post
    =MOD(I9,500)
    That's Clever

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: IF function with 3 options

    Please see attached file with formula.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    Re: IF function with 3 options

    I am running Excel 2007. I have attached a sample book. The cell (now E2) is the results of another formula [=LEFT(D2,3)], so it may be considered text.

    I have a list of about 600 different policy numbers, and I am just looking at the first 3 digits of them.
    Attached Files Attached Files

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF function with 3 options

    change e2 to =LEFT(D2,3)+0
    then you will have real numbers
    then use
    =IFERROR(MATCH(E2,{0,501,502},0)-1,"")
    or
    leave it as it is
    and use
    =IFERROR(MATCH(E2,{"0","501","502"},0)-1,"")

  11. #11
    Registered User
    Join Date
    06-11-2014
    Posts
    4

    Re: IF function with 3 options

    That worked! Thanks so much for your help! It is greatly appreciated!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. IF / OR / Function 3 options
    By Tyriel in forum Excel General
    Replies: 2
    Last Post: 07-15-2013, 02:41 PM
  2. IF function with multiple options
    By PAKTIRE in forum Excel General
    Replies: 1
    Last Post: 10-30-2009, 03:09 AM
  3. IF-function with multiple options+sum function
    By PALLE123 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-01-2007, 09:42 PM
  4. Copy Function Options
    By jonn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2007, 08:23 AM
  5. If function for multiple options?
    By sbweld in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-31-2006, 07:04 PM

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