+ Reply to Thread
Results 1 to 12 of 12

Formula needed to compare cells in two columns

  1. #1
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Formula needed to compare cells in two columns

    Hello... I have a table where I need to count the number of times the cell in Column B is >= to the corresponding cell in Column A. So looking at the below example, there are two situations where Column B ("Total Enrollment")=Column A ("Capacity"), so I need a formula that is going to give me a product of "2" in this situation. I hope this makes sense!
    Capture.PNG

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Formula needed to compare cells in two columns

    Hello
    try sumproduct

    =SUMPRODUCT((A1:A20=B1:B20)*(A1:A20<>""))
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula needed to compare cells in two columns

    Hi,

    Why not do it with a simply if statement and a helper column? See the attached.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Formula needed to compare cells in two columns

    vlady ~ Thank you!! That works

    MarvinP ~ The table is a query being fed into my workbook and I've been having problems with Excel removing the query every time I add helper columns, so I'm trying something new. But thanks anyway!
    Last edited by jlwilliams; 06-05-2012 at 11:15 AM.

  5. #5
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Formula needed to compare cells in two columns

    Hi vlady,

    Actually this did not work. I need it to include the instances when the number in Column A is bigger than the number in Column B, as well as when it's equal. How do I do that?

    Quote Originally Posted by vlady View Post
    Hello
    try sumproduct

    =SUMPRODUCT((A1:A20=B1:B20)*(A1:A20<>""))

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula needed to compare cells in two columns

    Try adding the > symbol

    =SUMPRODUCT((A1:A20>=B1:B20)*(A1:A20<>""))

  7. #7
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Formula needed to compare cells in two columns

    That does not give me what I'm looking for, but thanks anyway.

    Quote Originally Posted by Cutter View Post
    Try adding the > symbol

    =SUMPRODUCT((A1:A20>=B1:B20)*(A1:A20<>""))

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula needed to compare cells in two columns

    What is it that you're looking for - because firstly you said this:
    I need to count the number of times the cell in Column B is >= to the corresponding cell in Column A
    but then you said this:
    I need it to include the instances when the number in Column A is bigger than the number in Column B

  9. #9
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Formula needed to compare cells in two columns

    Oh gosh, I'm sorry. I'm confusing even myself! So I need to know if (for example) A2-B2<=0. Or in other words, as I said the first time, if B2 is greater than or equal to A2. And then I need to count the number of times this is the case in the entire table.

    This is a query table that gets refreshed weekly, so I need it to refresh the calculation each time as well.

    Quote Originally Posted by Cutter View Post
    What is it that you're looking for - because firstly you said this:


    but then you said this:

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula needed to compare cells in two columns

    If you're not concerned with checking for blank cells then you just need this:

    =SUMPRODUCT(--(B2:B100>=A2:A100))

  11. #11
    Registered User
    Join Date
    06-04-2012
    Location
    Idaho, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Formula needed to compare cells in two columns

    YES! YES, YES, YES!!! Thank you so much, Cutter!

    Quote Originally Posted by Cutter View Post
    If you're not concerned with checking for blank cells then you just need this:

    =SUMPRODUCT(--(B2:B100>=A2:A100))

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula needed to compare cells in two columns

    You seem very happy. You're welcome.

+ 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