+ Reply to Thread
Results 1 to 10 of 10

[solved]Count if cell from one column is equal to cell in other column

  1. #1
    Registered User
    Join Date
    09-17-2016
    Location
    Lithuania
    MS-Off Ver
    2013
    Posts
    11

    [solved]Count if cell from one column is equal to cell in other column

    Hello. I need a little help. It's been bothering me for hours now and I'm out of patience. I need to count how many times Number in Column A is equal to number in Column B. So A1=B1, A2=B2, A3=B3 and so on... I need answer in one cell (I could do it if I would use one more column for example in C1 I would write IF(A1=B1;1;0), C2 IF(A2=B2;1;0) and so on..., but I need more space efficient way now), I tried using COUNTIF(A:A;"="&B:B), COUNTIF(A:A;"=B:B), COUNTIF(A:A;B:B) and so on.. (I use A:A, B:B..., because it's quicker), but it doesn't give me the right number (actually, I get different numbers if I copy the same formula one row lower)..
    Last edited by Benderis; 09-17-2016 at 07:52 AM.

  2. #2
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Count if cell from one column is equal to cell in other column

    Try
    =SUMPRODUCT((A:A=B:B)*(A:A<>""))

  3. #3
    Registered User
    Join Date
    09-17-2016
    Location
    Lithuania
    MS-Off Ver
    2013
    Posts
    11

    Re: Count if cell from one column is equal to cell in other column

    I feel so dumb right now. Thank you VERY much.

  4. #4
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Count if cell from one column is equal to cell in other column

    You are welcomed

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count if cell from one column is equal to cell in other column

    Quote Originally Posted by José Augusto View Post
    Try
    =SUMPRODUCT((A:A=B:B)*(A:A<>""))
    You should avoid using entire columns as range references with the SUMPRODUCT function. Use small specific ranges.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    09-17-2016
    Location
    Lithuania
    MS-Off Ver
    2013
    Posts
    11

    Re: Count if cell from one column is equal to cell in other column

    Quote Originally Posted by Tony Valko View Post
    You should avoid using entire columns as range references with the SUMPRODUCT function. Use small specific ranges.
    Well.. It didn't take a long time to count (if that's the problem with it)..
    Last edited by Benderis; 09-17-2016 at 09:50 AM.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count if cell from one column is equal to cell in other column

    If you're satisfied with the performance that's all that counts!

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count if cell from one column is equal to cell in other column

    Just did a quick test in Excel 2010.

    Average calc times for these 2 formulas:

    =SUMPRODUCT((A1:A100=B1:B100)*(A1:A100<>""))

    =SUMPRODUCT((A:A=B:B)*(A:A<>""))

    Did 5 calculations and averaged those results.

    Formula1: 0.000842
    Formula2: 0.121852

    Time is in seconds

    As you can see Formula1 is significantly faster to calculate compared to Formula2.

  9. #9
    Registered User
    Join Date
    09-17-2016
    Location
    Lithuania
    MS-Off Ver
    2013
    Posts
    11

    Re: [solved]Count if cell from one column is equal to cell in other column

    I honestly did not expect for this community to be so generous. I already adjusted this formula to my needs (A2:A1090) for better performance (because the difference is big according to Tony's calculations)
    Big Thank You, Guys, for help.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: [solved]Count if cell from one column is equal to cell in other column

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 12-15-2014, 06:15 PM
  2. [SOLVED] Set cell equal to variable cell (from set column) based on cells in adjacent column
    By alter54 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2014, 01:04 PM
  3. [SOLVED] count number of cells in Column C that have a lesser or equal value to the adjacent cell
    By Geoff Jones in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-18-2013, 11:01 AM
  4. Replies: 4
    Last Post: 05-08-2013, 08:33 AM
  5. [SOLVED] Cond. formatting a column/Range, highlight cell in column/range if equal to specific text
    By DFrank231 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-19-2013, 03:35 PM
  6. Replies: 11
    Last Post: 01-18-2013, 04:05 PM
  7. Replies: 12
    Last Post: 09-06-2012, 07:24 PM

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