+ Reply to Thread
Results 1 to 10 of 10

If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    I am comfortable using simple IF statements but need some pointers using IF with multiple clauses.

    If A range of cells contains either Option A, Option B, or Option C, return 'Needs'. If the range doesn't contain any of the 3 options, return 'no needs'.

    If I was just comparing one cell with one possibility I would do similar to the following:

    =IF(C4="Option 1", Needs, No Needs)

    How do I adapt this when referring to a range, and when referring to more than one possible vales?


    Many thanks guys

    Henry

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    =if(Or(A1="Football",A1="Rugby",A1="Golf"),"Sporty","No Needs")
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    You may try:
    =IF(SUM(COUNTIF(range,{"Option 1","Option 2","Option 3"})),"Needs","No needs")
    or perhaps:
    =IF(OR(range={"Option 1","Option 2","Option 3"}),"Needs","No needs")
    Last edited by Izandol; 01-17-2014 at 11:28 AM.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    Hi Henry, perhaps
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

  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: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    Need some clarification.

    Is it...

    If ANY cell in the range contains ANY of the options.

    Or...

    If EVERY cell in the range contains ANY of the options?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    Good question Tony: I had in mind If ANY cell in the range contains ANY of the possible options.

    Thank you to everyone for the responses - each has worked in its own way.

    I wonder if there is a limit to how long a formula can be? because I have around 30 different possible options!

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    A function may have up to 255 characters. A nested if statement may have up to 64 levels. These are the EXCEL 2007 limitations.

    Look here for further information http://office.microsoft.com/en-us/ex...010073849.aspx

    Thanks for the feedback and the rep

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    If you have many options, you may use a range for those also:

    =IF(SUMPRODUCT(COUNTIF(range,criteria_range)),"Needs","No needs")

  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: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    With that many variables I would use Izandol's suggestion.

    FYI...

    Formula length:

    In Excel versions 2003 and earlier: 1,024 characters

    In Excel versions 2007 and later: 8,192 characters

  10. #10
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,831

    Re: If a range contains 'Football', 'Rugby', or 'Golf', return value 'Sporty'

    The word "contains" is a bit ambiguous, also - what if you had an entry of "Association Football", or "Rugby Union", or "Crazy Golf"?

    Pete

+ 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. [SOLVED] Return value if within range, return multiple values if ranges overlap
    By cde1983 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-17-2013, 06:16 AM
  2. Replies: 2
    Last Post: 11-12-2012, 06:26 AM
  3. [SOLVED] Football stats - calling football fans!
    By Steve_123 in forum Excel General
    Replies: 5
    Last Post: 05-18-2012, 09:15 AM
  4. Rugby World Cup 2011
    By teylyn in forum The Water Cooler
    Replies: 76
    Last Post: 10-25-2011, 06:22 AM
  5. Rugby predictions
    By rob1st in forum Excel General
    Replies: 4
    Last Post: 02-06-2010, 09:40 PM

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