+ Reply to Thread
Results 1 to 11 of 11

How do I evaluate a pair of cells

  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    MN
    MS-Off Ver
    Excel 2003
    Posts
    19

    How do I evaluate a pair of cells

    I have 6 columns and 5 rows of data I need a macro to compare the data in pairs. So if the data in A2 is greater than 30 and the data in B2 is greater than 30 then put the word “Pass” into A7 or “Fail” in A7 if not true. I need this to repeat for pairs C2 and D2, and E2 and F2. Then repeat the same for the remaining rows,see the attached example.

    Any help would be greatly appreciated!

    Thanks

    Jim
    Attached Files Attached Files

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: How do I evaluate a pair of cells

    In a7:

    =CHOOSE(AND(A2>30,B2>30)*1+1,"fail","pass")

    Copy down through A10, don't need a macro.


    edit- added attachment
    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-29-2012 at 10:28 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

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

  3. #3
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: How do I evaluate a pair of cells

    You can do this with a simple formula....put this into A7

    Please Login or Register  to view this content.
    if you want to do it with a macro then use

    Please Login or Register  to view this content.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: How do I evaluate a pair of cells

    this is just a good example of not needing a nested IF statement

  5. #5
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: How do I evaluate a pair of cells

    General i think its a matter of personal preference. To me my formula makes alot more sense than yours, yet they do the same thing. It just depends on what you are used to.

  6. #6
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: How do I evaluate a pair of cells

    agree...to a point. the problem is folks take nested IF's too far. Your example is still readable, but add a few more conditions and it becomes a headache. If people get more comfortable with not using IF statements for the easy problems, they don't get trapped using them on the harder cases.

    check out this blog, really good read on this: http://www.excelhero.com/blog/2010/01/i-heart-if.html

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How do I evaluate a pair of cells

    An argument for nested IFs is that they evaluate faster, which is insignificant in this case, but not in others.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: How do I evaluate a pair of cells

    You're right, I've seen some pretty gnarly if statements before, and they can be a pain to understand/modify.

  9. #9
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: How do I evaluate a pair of cells

    Quote Originally Posted by GaidenFocus View Post
    You're right, I've seen some pretty gnarly if statements before, and they can be a pain to understand/modify.

    Please Login or Register  to view this content.
    hows that?
    You need to make the condition a2+b2 > 60 evaluate to a specific number. If you use this: ((a2+b2)>60)*1+1, you will then have 2 cases: (False)*1+1 which evaluates to 1 or (True)*1+1 which evaluates to 2.

    Then, you tell Choose what the function should return for the 1 and 2 case: "pass" for 1, and "fail" for 2.

    Basically, statement like (B1>30) evaluate to TRUE or FALSE and when you use those statements in a multiplication statement, they are read as true=1 and false=0.

  10. #10
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: How do I evaluate a pair of cells

    Yea i deleted it before you responded simply because if one of the values is 60 or above and the other value is 1 or above it would be a false positive.

  11. #11
    Registered User
    Join Date
    05-31-2012
    Location
    MN
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: How do I evaluate a pair of cells

    Thanks, I have a lot larger file then my example, I was looking for code that would loop through the entire range of each pair of cells in my example, not just "a2" and "b2". If you have any suggestions I would greatly appreciate it.

+ 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