+ Reply to Thread
Results 1 to 11 of 11

Sumproduct/countifs

  1. #1
    Registered User
    Join Date
    07-10-2014
    Location
    Waco, TX
    MS-Off Ver
    2010
    Posts
    63

    Sumproduct/countifs

    I'm trying to figure out the rest if this formula and have tried several things, without success.

    =SUMPRODUCT(D:D,--ISNUMBER(MATCH(C:C,{"July","August","September"},0)))

    The above function finds those cells in Column C with the texts "July", "August", "September" and sums the figures beside them in Column D. Now I need to finish the formula, dividing it by the total number of such occurrences to obtain an average figure. There are blank cells in this worksheet.

    Can anybody help me? Thanks.

  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,938

    Re: Sumproduct/countifs

    Hi and welcome to the forum

    1st, try and avoid using entire columns (or rows) when using sumproduct(), it will start to slow your file down - try and restrict it to a range 2-3 times larger than you thing you will need.

    2nd, you could probably use sumifS() and countifS() if you could use real dates instead of just month names
    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
    07-10-2014
    Location
    Waco, TX
    MS-Off Ver
    2010
    Posts
    63

    Re: Sumproduct/countifs

    I could follow the first, but not the second suggestion because the month names are text which are populated into those cells by another VBA code.

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

    Re: Sumproduct/countifs

    Maybe this...

    =SUM(SUMIF(C:C,{"July","August","September"},D:D))/SUM(COUNTIF(C:C,{"July","August","September"}))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    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,938

    Re: Sumproduct/countifs

    If you were using real dates instead of text "dates", you could use something like this...

    =SUMIFS(D:D,C:C,">=7/1/14",C:C,"<=9/30/14")
    and then...
    =COUNTIFS(C:C,">=7/1/14",C:C,"<=9/30/14")

  6. #6
    Registered User
    Join Date
    07-10-2014
    Location
    Waco, TX
    MS-Off Ver
    2010
    Posts
    63

    Re: Sumproduct/countifs

    That is the ticket! Thank you very much, Mr. Valko

  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: Sumproduct/countifs

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

  8. #8
    Registered User
    Join Date
    07-10-2014
    Location
    Waco, TX
    MS-Off Ver
    2010
    Posts
    63

    Re: Sumproduct/countifs

    Oops! Hmm. Mr. Valko, the formula is giving me a DIV/0 Error because there are blank cells. Is there a work-around for that?

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

    Re: Sumproduct/countifs

    Empty cells should not cause an error unless ALL of the cells are empty.

    You'll get the #DIV/0! error if the COUNTIF = 0.

    You could get an incorrect result if cells in column D are empty but the corresponding cells in column C contain one of the criteria months.

    Which column has the empty cells?

  10. #10
    Registered User
    Join Date
    07-10-2014
    Location
    Waco, TX
    MS-Off Ver
    2010
    Posts
    63

    Re: Sumproduct/countifs

    You are correct, I had all empty cells in one section. Much appreciated.

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

    Re: Sumproduct/countifs

    Ok, you can prevent the #DIV/0! error with this version:

    =IFERROR(SUM(SUMIF(C:C,{"July","August","September"},D:D))/SUM(COUNTIF(C:C,{"July","August","September"})),"")

    That'll return a blank instead of any errors.

+ 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] Is there a way to combine COUNTIFS and SUMPRODUCT?
    By ogbugsy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2013, 08:18 AM
  2. COUNTIFS and SUMPRODUCT help
    By Stacy1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-19-2013, 02:35 PM
  3. [SOLVED] COUNTIF vs COUNTIFS vs SUMPRODUCT
    By FASTiger in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-28-2013, 01:44 AM
  4. HELP CONVERT SUMPRODUCT to COUNTIFS
    By chie in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-09-2013, 07:35 AM
  5. Using SUMPRODUCT instead of COUNTIFS
    By SymphonyTomorrow in forum Excel General
    Replies: 12
    Last Post: 11-18-2011, 05:01 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