+ Reply to Thread
Results 1 to 5 of 5

Sum multiple COUNTIF statements in a single formula

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    24

    Sum multiple COUNTIF statements in a single formula

    I am working with an attendance sheet, and I am trying to calculate whether a particular person attended either of the two sessions on Friday (Session 1 is Column B and Sessions 2 is column C) and either of the two sessions on Saturday (Sessions 1 is Column E and Session 2 is Column E).

    I have written a formula that assigns a value of 1 if the person attends at least 1 session on both Friday and Saturday:
    =IF(SUM(IF(COUNTIF(B3:C3, "x")>=1, 1, 0)+IF(COUNTIF(D3:E3, "x")>=1, 1, 0))=2, 1, 0)

    In a single formula, how would I sum all those formulas for rows 3 to 10, for example? (I presume some sort of sum/sumproduct formula)

    I've attached a workbook if that's helpful.

    Thanks in advance,

    Ben
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Sum multiple COUNTIF statements in a single formula

    Maybe this?
    F3, copied down....
    =IF(COUNTIF(B3:C3, "x")>=1, 1, 0)+IF(COUNTIF(D3:E3, "x")>=1, 1, 0)
    I9=COUNTIF(F3:F6,2)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-26-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Sum multiple COUNTIF statements in a single formula

    Thanks for your response, Ford. I am actually trying to calculate the value with just 1 formula on the page if that's possible.

    I am basically trying to write a formula that does:

    =IF(COUNTIF(B3:C3, "x")>=1, 1, 0)+IF(COUNTIF(D3:E3, "x")>=1, 1, 0) +
    IF(COUNTIF(B4:C4, "x")>=1, 1, 0)+IF(COUNTIF(D4:E4, "x")>=1, 1, 0) +
    IF(COUNTIF(B5:C5, "x")>=1, 1, 0)+IF(COUNTIF(D5:E5, "x")>=1, 1, 0) +
    IF(COUNTIF(B6:C6, "x")>=1, 1, 0)+IF(COUNTIF(D6:E6, "x")>=1, 1, 0) +
    IF(COUNTIF(B7:C7, "x")>=1, 1, 0)+IF(COUNTIF(D7:E7, "x")>=1, 1, 0) +
    IF(COUNTIF(B8:C8, "x")>=1, 1, 0)+IF(COUNTIF(D8:E8, "x")>=1, 1, 0) +
    etc., etc.

    I would like to sum all the rows if possible, but at the very least to row 250! I hope that clarifies my question / the solution I am looking for.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Sum multiple COUNTIF statements in a single formula

    Quote Originally Posted by bfs3 View Post
    I would like to sum all the rows if possible, but at the very least to row 250!
    Try this formula

    =SUMPRODUCT(((B3:B250="x")+(C3:C250="x")>0)+0)+SUMPRODUCT(((D3:D250="x")+(E3:E250="x")>0)+0)

    edit: that's based on your last post where you seem to be counting 1 for every pair of cells - if you want to count rows only if both pairs of cells in each row have at least one "x" (i.e. to get 2 in your example) then that would be this version

    =SUMPRODUCT(((B3:B250="x")+(C3:C250="x")>0)*((D3:D250="x")+(E3:E250="x")>0))

    You can expand it for any number of rows
    Last edited by daddylonglegs; 02-17-2014 at 07:27 PM.
    Audere est facere

  5. #5
    Registered User
    Join Date
    06-26-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Sum multiple COUNTIF statements in a single formula

    Thanks, daddylonglegs. Formula works great.

+ 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] COUNTIF Formula to Return Multiple Values in a Single Column
    By TommyK25 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-05-2013, 05:01 AM
  2. How to generate multiple statements from single table?
    By crimmo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-26-2013, 11:04 AM
  3. Using Multiple IF statements within single formula
    By JonathanMoore in forum Excel General
    Replies: 8
    Last Post: 09-14-2011, 12:30 PM
  4. multiple IF and COUNTIF statements
    By Kwarren in forum Excel General
    Replies: 4
    Last Post: 12-29-2009, 02:43 PM
  5. Multiple COUNTIF Statements
    By Kwarren in forum Excel General
    Replies: 7
    Last Post: 09-17-2009, 04:04 PM

Tags for this Thread

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