+ Reply to Thread
Results 1 to 9 of 9

Need help with the IF function in Excel 2007

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Gatineau, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Need help with the IF function in Excel 2007

    Hello!
    I need help with an IF function in Excel 2007.
    I need the IF formula to put a "1" if the word "YT" or "BC" or "Pacific_Ocean" is in cell J2:V2. If none of these words are there, I want the IF formula to put a "0".

    I have written the following formula but it contains an error:
    =IF(OR(J2:V2="YT",J2:V2="BC",J2:V2="Pacific_Ocean")"1", "0")
    Can you please help!
    Thanks a lot!
    Last edited by XavierC; 04-15-2013 at 02:30 PM. Reason: Solved

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

    Re: Need help with the IF function in Excel 2007

    Try

    =--(SUM(COUNTIF(J2:V2,{"YT","BC","Pacific_Ocean"}))>0)

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need help with the IF function in Excel 2007

    =IF(OR(COUNTIF(J2:V2, "YT"), COUNTIF(J2:V2, "BC"), COUNTIF(J2:V2, "Pacific_Ocean")), 1, 0)
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Need help with the IF function in Excel 2007

    ASnother solution

    =IF(SUMPRODUCT((J2:V2="YT")+(J2:V2="BC")+(J2:V2="Pacific_Ocean"))>0,1,0)
    Appreciate the help? CLICK *

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

    Re: Need help with the IF function in Excel 2007

    Try this array formula**:

    =--OR(J2:V2={"YT";"BC";"Pacific Ocean"})

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    04-15-2013
    Location
    Gatineau, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Need help with the IF function in Excel 2007

    Thank you very much all for your quick reply!

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

    Re: Need help with the IF function in Excel 2007

    You're welcome, we appreciate the feedback.

  8. #8
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Need help with the IF function in Excel 2007

    Exactly

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

    Re: Need help with the IF function in Excel 2007

    You're welcome!

+ 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