+ Reply to Thread
Results 1 to 8 of 8

Thread: Or Function

  1. #1
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    180

    Or Function

    I have a set of values to test Say 4 Cells. How would I return true only if a certain amount of them qualify as true. I want to do this in a function.

    Ex: I test all 4 cells but I want it to be true only if 3 of the Cells return true.

    or

    I test all 4 cells but I want it to be true only if 1 of the Cells return true,

    etc....

    I know this would be possible some how but how? I tried to do a search on the web but cannot find a solution.

  2. #2
    Valued Forum Contributor Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens Greece
    MS-Off Ver
    Excel 2003
    Posts
    2,297

    Re: Or Function

    Hi

    Looks to me that you need an IF(AND---OR...function. For Example.

    =IF(AND(A1=B1;A2=B2;A3=B3);SUM(B1:B10);"")>>All 3 conditions for summing range B1:B10.

    =IF(OR(A1=B1;A2=B2;A3=B3);SUM(B1:B10);"")>> 1 of 3 conditions for summing range B1:B10.

    Hope to helps you.
    Regards

    Fotis.

    I am proud that i am Greek.

    Just to know every one.We Greeks, we are nοt proud of our politicians. Υou?

    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.

    Please,mark your thread [SOLVED] if you received your answer.


    My Avadar picture, is from Athens Acropolis.
    http://www.theacropolismuseum.gr

    http://www.visitgreece.gr/

  3. #3
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,711

    Re: Or Function

    Not sure what makes a cell "true".

    This formula returns TRUE if only 3 of the cells in A1:D1 contain the word "Yes"
    E1: =COUNTIF(A1:D1,"Yes")=3

    Examples:
    Yes Yes No Yes = TRUE
    Yes Yes Yes Yes = FALSE

    Does that hep?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  4. #4
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Or Function

    Ron,

    Thank you that looks like it would work. I had to modify it a little bit and here is what I got:

    =COUNTIFS(E5,"<0",I5,"<0",M5,"<0",Q5,"<0",U5,"<0",Y5,"<0")

    However, it is not coming out correct. I want it to count it if that cell is less than 0. After I figure that out than I will put in the if Statement to return true if value = 3 and so on.

  5. #5
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,711

    Re: Or Function

    Quote Originally Posted by djblois1 View Post
    =COUNTIFS(E5,"<0",I5,"<0",M5,"<0",Q5,"<0",U5,"<0",Y5,"<0")
    That formula returns the count where ALL of those criteria are true.

    This regular formula returns the count of the referenced cells that are less than zero
    =SUM(COUNTIF(OFFSET(E5,,{0,4,8,12,16,20}),"<0"))
    Is that something you can work with?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  6. #6
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Or Function

    That works perfectly in a cell but Now I need to put it in conditional formation and it says that it will not work with Conditional formatting.

  7. #7
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,711

    Re: Or Function

    Quote Originally Posted by djblois1 View Post
    That works perfectly in a cell but Now I need to put it in conditional formation and it says that it will not work with Conditional formatting.
    That's very different...It's important to give as much information as you can.
    Conditional formatting doesn't allow any form of array or array formula.
    Try this regular formula:
    =SUMPRODUCT(--(((MOD((COLUMN(E5:Y5)-1),4)=0)*E5:Y5)<0))=2
    Is that something you can work with?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  8. #8
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Or Function

    Sorry, I did not know there was a difference.

+ 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.2.0