+ Reply to Thread
Results 1 to 9 of 9

IF OR function help

  1. #1
    Registered User
    Join Date
    04-16-2012
    Location
    USA
    MS-Off Ver
    Excel 2010 Win and Mac
    Posts
    3

    Question IF OR function help

    Hello All

    I am trying to use the IF OR function while validating specific text in a column and am totally lost. Can anyone help me to understand this?

    My goal is that if anything in column B1 to B5 = Yes or Maybe then the sum of the numbers in A1 to A5 would be returned for the rows that have Yes or Maybe and not the ones with No in them.

    Here is the function that I thought would work however it only returns #Value
    =IF(OR(B1:B5="Yes",B1:B5="Maybe"),SUM(A2:A5))

    *Side not for my learnings; I have successfully been able to do this with only 1 condition using the following function. However I do not understand why the * is needed before and after the text inside the quotation marks. But really I need the OR function here if feasible.
    =SUMIF(B1:B5,"*Rotating*",A1:A5)

    Cheers,

    Reid
    Last edited by reido113; 04-16-2012 at 02:46 PM. Reason: clarity

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: IF OR function help

    The *s are "wildcards" so in your SUMIF

    =SUMIF(B1:B5,"*Rotating*",A1:A5)

    that will sum A1:A5 when the corresponding row contains "rotating" (possibly within other text), rather than being exactly equal to "rotating". For an OR effect try this version

    =SUM(SUMIF(B1:B5,{"Yes","Maybe"},A1:A5))
    Audere est facere

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF OR function help

    This one is much trickier than you may think, for a number of reasons, but this should work:

    =SUMPRODUCT(A1:A5,--(LEN(B1:B5)>2))

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: IF OR function help

    Hi

    Try this.

    =SUMPRODUCT((B2:B5="YES")*(C2:C5="Maybe")*(A2:A5))
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF OR function help

    Quote Originally Posted by Fotis1991 View Post
    =SUMPRODUCT((B2:B5="YES")*(C2:C5="Maybe")*(A2:A5))
    Where's column C come from? You can't multiply together the Booleans for "Yes" and "Maybe", because if you do it will only sum rows where column B is both "Yes" and "Maybe".

  6. #6
    Registered User
    Join Date
    04-16-2012
    Location
    USA
    MS-Off Ver
    Excel 2010 Win and Mac
    Posts
    3

    Re: IF OR function help

    Thanks Y'all. I breath a sigh of relief!
    daddylonglegs Thanks for the explanation of the wildcards here. And your function worked Perfectly! I have now found a use for squiggles too

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: IF OR function help

    My SUMIF was explicitly summing for "Yes" and Maybe" - if that's the same as summing when not equal to "No" then you can just do that

    =SUMIF(B1:B5,"<>No",A1:A5)

  8. #8
    Registered User
    Join Date
    04-16-2012
    Location
    USA
    MS-Off Ver
    Excel 2010 Win and Mac
    Posts
    3

    Re: IF OR function help

    I see. In my actual deeper case there are many more combinations of texts to consider.
    ...should that actually be <>"no" ?

    *edit* I should have tried first, sorry. Disregard and Thanks Again. This I am sure will come in handy.

    Cheers
    Last edited by reido113; 04-16-2012 at 03:09 PM.

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: IF OR function help

    @Andrew-R

    ...Where's column C come from? You can't multiply together the Booleans for "Yes" and "Maybe", because if you do it will only sum rows where column B is both "Yes" and "Maybe".
    Column C, came from nowhere....! I ...just show column C, in first OP question.....

    ..And, Andrew, please,my knowdledge is not so bad, to don't let me to know, what is a simple SUMPRODUCT, does...

    Yes, i did not understand the question, just my answer was wrong... ...Just this.

+ 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