+ Reply to Thread
Results 1 to 9 of 9

Excel Formulas - Many OR Statements

  1. #1
    Registered User
    Join Date
    03-11-2013
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Excel Formulas - Many OR Statements

    Hello,

    I would like to write the following in a more compact form:

    =IF(OR(A1>B1,A2>B2,A3>B3,...,A99>B99,A100>B100),1,0)

    Basically, I want to check row by row if Ax is greater than Bx and, if true for any row (or rows), return 1 else 0.

    This would also help me answer another thread I have, so two birds with one stone!

    Thanks,
    Nik

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

    Re: Excel Formulas - Many OR Statements

    Try this formula

    =IF(SUMPRODUCT((A1:A100>B1:B100)+0)>0,1,0)
    Audere est facere

  3. #3
    Registered User
    Join Date
    03-02-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Excel Formulas - Many OR Statements

    Quote Originally Posted by daddylonglegs View Post
    Try this formula

    =IF(SUMPRODUCT((A1:A100>B1:B100)+0)>0,1,0)
    This one works should work perfectly......

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Excel Formulas - Many OR Statements

    Daddylonglegs' should be shorter a bit:
    =--(SUMPRODUCT(--(A1:A100>B1:B100))>0)
    Or CSE:
    =--OR(A1:A100>B1:B100)
    Quang PT

  5. #5
    Registered User
    Join Date
    03-11-2013
    Location
    Edmonton, Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Excel Formulas - Many OR Statements

    Haha, thank you! I have no clue why that works, but that's what I wanted! If you don't mind me asking, why is the "+0" necessary? And what does it mean to sum the array A1:A100>B1:B100?

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Excel Formulas - Many OR Statements

    A1:A100>B1:B100 = {A1>B1;A2>B2;...;A100>B100} ={TRUE;FALSE;TRUE;...}
    With TRUE~1, FALSE~0
    --(A1:A100>B1:B100)
    or
    (A1:A100>B1:B100)*1
    or
    (A1:A100>B1:B100)+0
    will convert text to number
    ={1;0;1;...}
    SUMPRODUCT will sum all items to get the total.
    If SUMPRODUCT(...)>0, that means there is at least 1 to be counted.

  7. #7
    Registered User
    Join Date
    02-14-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel Formulas - Many OR Statements

    Hi Nik,

    The desired output can be achieved using formula =IF(A1>B1,1,0) at column C and drag.

    Regards,

    VS

  8. #8
    Registered User
    Join Date
    03-02-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Excel Formulas - Many OR Statements

    Quote Originally Posted by Vicky Singh View Post
    The desired output can be achieved using formula =IF(A1>B1,1,0) at column C and drag.
    Hi Vicky!
    It won't work... He wants only one cell to give him a True or Fasle if any of the A's is greater than it's corresponding B's...

    Have fun,
    Jason

  9. #9
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Excel Formulas - Many OR Statements

    DUPLICATE THREAD

    Duplicate here: http://www.excelforum.com/excel-form...31#post3154431

    nikolasm, please refrain, per the Forum rules, from duplicating posts - this can result in forum members wasting the time they are donating to help others, as the query may have been answered in the duplicate thread.
    Brendan.


    __________________________________________________________________________________________________
    Things to consider:

    1) You can thank any poster by clicking the * at the left of a helpful post.
    2) You can help to keep the forum tidy by marking your thread as "Solved", if it has been answered to your satisfaction.
    3) Help us to help you, by uploading a sample workbook, showing the type of data you're dealing with, and clearly indicating what the results should be.

+ 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