+ Reply to Thread
Results 1 to 12 of 12

Using 'IF' function with an 'OR' range

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    24

    Using 'IF' function with an 'OR' range

    Hi

    I am getting stuck with something I thought would be more straightforward!

    I am writing the following formula which I hoped would give me a 'yes' if cell B3 contains any one of the values I have in a range list (C5:C9). Then if it's not true, give me 'no'. I will be using the formula down column B.

    =IF(B3=OR($C$5:$C$9),"yes","no")

    Unfortunately, I receive the #VALUE! error.

    How can I update this to give me what I'm after? I've attached a sheet that might make this ask more explicit.

    Thanks very much for any advice!
    Attached Files Attached Files

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Using 'IF' function with an 'OR' range

    maybe try this instead... =IFERROR(IF(VLOOKUP(B3,C5:C9,1,FALSE)=B3,"yes"),"no")
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Using 'IF' function with an 'OR' range

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Using 'IF' function with an 'OR' range

    That's not the way to do it. By the way, are you REALLY using Excel 2007 (apologies if I've asked this before)?

    Try this instead:

    =IF(ISERROR(MATCH(B3,$C$5:$C$9,0)),"No","Yes")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Using 'IF' function with an 'OR' range

    Or try this:

    =IF(COUNTIF($C$5:$C$9,B3)>0,"Yes","No")

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Using 'IF' function with an 'OR' range

    Lots of ways to skin this cat, just not with the OR function!!!

  7. #7
    Registered User
    Join Date
    06-19-2013
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    24

    Re: Using 'IF' function with an 'OR' range

    Wow, thanks all for the quick responses. I can see there are better options out there!

    Why is it that the formula doesn't work - is it something to do with it being a range? It would just be nice to know why it went wrong.


    AliGW, I am using a later version but perhaps the saved file is old. I have 2016 I believe.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Using 'IF' function with an 'OR' range

    You have either 2016 (standalone) or 365 (subscription), but you now have both in your profile???

    Have a look here: https://exceljet.net/excel-functions/excel-or-function

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Using 'IF' function with an 'OR' range

    If you want to use the OR function, try an array formula**:

    =IF(OR($C$5:$C$9=B3),"Yes","No")


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  10. #10
    Registered User
    Join Date
    06-19-2013
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    24

    Re: Using 'IF' function with an 'OR' range

    that's exactly what I was trying to accomplish, nice to know it can be done with OR, it's just making it show as an array formula :

    {=IF(OR($C$5:$C$9=B3),"Yes","No")}

  11. #11
    Registered User
    Join Date
    06-19-2013
    Location
    Manchester, England
    MS-Off Ver
    Office 365
    Posts
    24

    Re: Using 'IF' function with an 'OR' range

    Quote Originally Posted by AliGW View Post
    You have either 2016 (standalone) or 365 (subscription), but you now have both in your profile???
    I need to amend that , it is the 365 subscription provided through my organisation

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Using 'IF' function with an 'OR' range

    Yes, please - the two versions do differ considerably!

+ 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] VBA or Function to delete Any string on multiples Range that Match range reference
    By AndyJr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2019, 11:41 PM
  2. [SOLVED] Setting the Range of a Worksheet Function using the Location of the overall Function Input
    By shouwiz in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-31-2018, 08:23 PM
  3. Replies: 3
    Last Post: 08-14-2017, 06:26 AM
  4. Replies: 1
    Last Post: 11-24-2015, 03:00 AM
  5. Replies: 6
    Last Post: 11-08-2014, 07:07 PM
  6. Replies: 15
    Last Post: 06-24-2014, 09:27 AM
  7. Replies: 15
    Last Post: 09-10-2013, 05:31 AM

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