+ Reply to Thread
Results 1 to 7 of 7

Count cells that are equal with condition

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Question Count cells that are equal with condition

    This is what I'm trying to automate:

    Capture.JPG

    I have a list of data in Table1.
    In column G I want to calculate the number of instances Joe, Bill and Marta have the same figures in Table1[ColumnB] and in Table1[ColumnC]. I.e. the red cells for each name.

    I've come up with ={SUM(IF(Table1[ColumnB]<>Table1[ColumnC];1;0))}, which gives me the grand total of equal cells, but I want to break it down to each name as well.



    I could insert a calculation in ColumnD with

    =IF([@[ColumnB]]<>[@[ColumnC]];1;0)

    ...which would add 1 when ColumnB and ColumnC are equal

    ... and in Column G sum it up with

    =SUMIFS(Table1[ColumnD];Table1[ColumnA];$F2) note: (F2 = Joe)

    ... but I want to do it all in one calculation without adding columns

    Help!
    Last edited by ottoex; 09-15-2013 at 07:55 AM.

  2. #2
    Registered User
    Join Date
    06-30-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Count cells that are equal with condition

    check this out I think that what u want

    Book2.xlsx

  3. #3
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Count cells that are equal with condition

    G2: =SUMPRODUCT((A$1:A$7=F2)*(B$1:B$7=C$1:C$7))

    copy down

  4. #4
    Registered User
    Join Date
    01-24-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Count cells that are equal with condition

    Quote Originally Posted by Teethless mama View Post
    G2: =SUMPRODUCT((A$1:A$7=F2)*(B$1:B$7=C$1:C$7))

    copy down
    Quote Originally Posted by pwnyadav007 View Post
    check this out I think that what u want

    Attachment 265414
    Both works, thanks guys!

    I've never used =sumproduct before and I'm trying to figure out how it works, as it seems to be a "neater" solution than using nested ifs (no disrespect pwnyadav007!)

    Why do you use multiplication teethless mama?

  5. #5
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Count cells that are equal with condition

    Quote Originally Posted by ottoex View Post
    Both works, thanks guys!

    I've never used =sumproduct before and I'm trying to figure out how it works, as it seems to be a "neater" solution than using nested ifs (no disrespect pwnyadav007!)

    Why do you use multiplication teethless mama?
    The multiplication turns TRUE/FALSE into 1/0. The SUMPRODUCT is use to add them all up.
    Last edited by Teethless mama; 09-16-2013 at 08:51 PM.

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

    Re: Count cells that are equal with condition

    See this for more info on SUMPRODUCT:

    http://xldynamic.com/source/xld.SUMPRODUCT.html
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: Count cells that are equal with condition

    You can even use the countif formula for this request.

    =countif("A1:B2000","joe")

    This will give you number of occurrences of joe in the range A1:B2000

    _________________________________________________________________________________________________________________
    please click * to say thank you

    “I have not failed. I've just found 10,000 ways that won't work.”
    ― Thomas A. Edison

+ 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. [SOLVED] Count cells less than or equal to zero
    By greeneggsandsam in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-28-2013, 04:12 PM
  2. Excel 2007 : Count number of cells less than or equal to today's date
    By marthadanielle in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-10-2013, 08:13 PM
  3. [SOLVED] Formulas count cells that do NOT equal a cell
    By boll55 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-01-2012, 08:53 AM
  4. Count cells with condition
    By Amanda in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-09-2005, 02:05 PM
  5. Count cells with length not equal to 7
    By cottage6 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-07-2005, 04:06 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