If, and, or
Results 1 to 5 of 5

Thread: If, and, or
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jan 2018
    Location
    Kentucky
    Posts
    174
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default If, and, or

    Scenario: I am trying to find the best way to search one row across ten non consecutive columns to see if criteria is met. This row is one of a thousand and the columns are ten of ninety-five. My goal is: If B3="V" AND AF3="B" AND Q3-AQ3 <=|2.25| OR AH3="B" AND Q3-AS3 <=|2.25| OR AJ3="B" AND Q3-AU3 <=|2.25| OR AL3="B" AND Q3-AW3 <=|2.25|OR AN3="B" AND Q3-AY3 <=|2.25|OR AP3="B" AND Q3-BA3 <=|2.25|OR AR3="B" AND Q3-BC3 <=|2.25|OR AT3="B" AND Q3-BE3 <=|2.25| OR AV3="B" AND Q3-BG3 <=|2.25| OR AX3="B" AND Q3-BI3 <=|2.25|then TRUE. I know there's a way to nest this but I can't figure out how to get it to work. Everything I've tried has gotten errors so I wanted to ask you guys for suggestions.
    Thank you in advance for any assistance.

  2. #2
    Board Regular
    Join Date
    Jan 2018
    Location
    Kentucky
    Posts
    174
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: If, and, or

    Looking at this post is dang confusing so let me try to reword it:
    If B3="V" AND
    AF3="B" AND Q3-AQ3 <=|2.25|
    OR AH3="B" AND Q3-AS3 <=|2.25|
    OR AJ3="B" AND Q3-AU3 <=|2.25|
    OR AL3="B" AND Q3-AW3 <=|2.25|
    OR AN3="B" AND Q3-AY3 <=|2.25|
    OR AP3="B" AND Q3-BA3 <=|2.25|
    OR AR3="B" AND Q3-BC3 <=|2.25|
    OR AT3="B" AND Q3-BE3 <=|2.25|
    OR AV3="B" AND Q3-BG3 <=|2.25|
    OR AX3="B" AND Q3-BI3 <=|2.25|
    then true.
    I've tried doing each step then nesting into one formula, but as I mentioned I keep getting errors.

  3. #3
    MrExcel MVP Eric W's Avatar
    Join Date
    Aug 2015
    Location
    Bountiful, UT
    Posts
    8,472
    Post Thanks / Like
    Mentioned
    42 Post(s)
    Tagged
    5 Thread(s)

    Default Re: If, and, or

    First, I think you mean |Q3-AQ3| <= 2.25, or the difference between Q3 and AQ3 is less than 2.25. If so, you can write your formula like this:

    =IF(B3="V",IF(OR(AND(AF3="B",ABS(Q3-AQ3)<=2.25),AND(AH3="B",ABS(Q3-AS3)<=2.25),AND(AJ3="B",ABS(Q3-AU3)<=2.25),AND(AL3="B",ABS(Q3-AW3)<=2.25),AND(AN3="B",ABS(Q3-AY3)<=2.25),AND(AP3="B",ABS(Q3-BA3)<=2.25),AND(AR3="B",ABS(Q3-BC3)<=2.25),AND(AT3="B",ABS(Q3-BE3)<=2.25),AND(AV3="B",ABS(Q3-BG3)<=2.25),AND(AX3="B",ABS(Q3-BI3)<=2.25)),TRUE))

    Somewhat large, but straightforward. You can also use this shorter version:

    =IF(B3="V",IF(SUMPRODUCT(COUNTIF(OFFSET(AF3,0,{0,2,4,6,8,10,12,14,16,18}),"B"),--(ABS(Q3-SUBTOTAL(9,OFFSET(AQ3,0,{0,2,4,6,8,10,12,14,16,18})))<2.25)),TRUE))

    which also works, but is a bit trickier.
    Cheers,
    Eric

    When you eliminate the impossible, whatever remains, however improbable, must be the truth.

    -Posting guidelines, forum rules, terms of use, FAQs, BB codes, See how to search the forum
    -Post a screen shot with the HTML Maker

  4. #4
    Board Regular Gerald Higgins's Avatar
    Join Date
    Mar 2007
    Location
    Edinburgh
    Posts
    9,084
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: If, and, or

    Perhaps something like this for a simplified version, which might get you started.

    =if(and(B3="V",or(and(AF3="B",(Q3-AQ3)<=2.25),and(AH3="B",(Q3-AQ3)<=2.25)),TRUE,FALSE)

    I think this works for two conditions, perhaps you can work out how to extend it to more conditions.

    BUT, you have hinted that there may be MANY MORE conditions that you want to test.
    If that's the case, there might well be better ways of doing this.
    The following is my SIGNATURE. It's not part of any question or solution I'm posting. If it IS your solution, you've got a very weird problem !

    Sub Macro()
    ActiveCell = "IY" & Right(Application.Name, 5)
    With ActiveCell.Characters(Start:=2, Length:=1).Font
    .Name = "Webdings"
    .Color = 255
    End With
    End Sub

  5. #5
    MrExcel MVP
    Join Date
    Aug 2010
    Location
    Rio de Janeiro BRAZIL
    Posts
    16,239
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    8 Thread(s)

    Default Re: If, and, or

    Maybe this array formula...

    =AND(B3="V",SUM(IF(MOD(COLUMN(AF3:AX3)-COLUMN(AF3)+1,2)=1,IF(AF3:AX3="B",IF(ABS(Q3-AQ3:BI3)<=2.25,1))))>0)
    confirmed with Ctrl+Shift+Enter, not just Enter

    M.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •