+ Reply to Thread
Results 1 to 6 of 6

Count if for two cells

  1. #1
    Forum Contributor
    Join Date
    02-26-2010
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    164

    Smile Count if for two cells

    I need a formula that will count how many cells that have "x" showing up only if another cell in the same row is "y".


    For example,

    I need to count how many times "sports" shows up in column B ONLY if column D has the name David in the same row.


    Below is a thread I made recently that is similar to the question I have now however the link below shows how to sum. I just need to count the cells, not sum.


    http://www.excelforum.com/excel-gene...-criteria.html
    Last edited by Statz; 11-12-2010 at 11:44 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,949

    Re: Count if for two cells

    Assuming the values Sports would be in Column A and David in Column B. Data is in rows 1-10

    =sumproduct((A1:A10="Sports")*(B1:B10="David"))
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    11-10-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Count if for two cells

    Not sure how large your excel file is, but how about a column that indicates whether there is Y, whether there is X and whether there is both X and Y? Then sum up that column...

    In the below code, substitute "y" for "david", exchange b1 for the first cell of column Y, substitute "x" for "sports", exchange a1 for the first cell of column X.

    Then exchange "can't find X" with 0 and "cant find Y" with 0, and "Has X and Y" with 1.

    Auto format from the top to the bottom of your data and sum up that column.

    Code to understand what I'm doing:
    Please Login or Register  to view this content.
    Code Formatted for you:
    Please Login or Register  to view this content.
    Last edited by Johnny_Drama; 11-11-2010 at 10:07 PM.

  4. #4
    Registered User
    Join Date
    11-10-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Count if for two cells

    Wait a minute,

    I just realized how easy this is to do. Just use a simple countifs

    a1:a10 is the range for sports and b1:b10 is the range for david
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,949

    Re: Count if for two cells

    Countifs is a 2007 function. OP is using 2003.

    Alan

  6. #6
    Forum Contributor
    Join Date
    02-26-2010
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    164

    Re: Count if for two cells

    Quote Originally Posted by alansidman View Post
    Assuming the values Sports would be in Column A and David in Column B. Data is in rows 1-10

    =sumproduct((A1:A10="Sports")*(B1:B10="David"))

    thank you this worked!!

+ 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