+ Reply to Thread
Results 1 to 17 of 17

SUMPRODUCT if Fields Match a RANGE of Criteria

  1. #1
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    SUMPRODUCT if Fields Match a RANGE of Criteria

    I'd like to be able to use SUMPRODUCT to sum up a range of cells for which its category corresponds to a list of my criteria.

    For example (see attached), I want to sum up all cells in column B with a Category of A, B, or C (which is listed out in a range in column A), resulting in an output of 325 (orange cells). I'd like to be able to add whatever category I want to Column A, so the sumproduct criteria must refer to a range of cells. In other words, I can use OR in the sumproduct to achieve the same effect but I'd rather not because the Criteria lists can get quite large.

    sumproduct.png

    I believe the formula will look something like:

    =SUMPRODUCT(B2:B10,--(C2:C10=??????))
    Last edited by jtang128; 03-05-2015 at 03:51 PM.

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Picture files will not download for many of us. Please upload Excel file of what you describe. It also saves having to retype your data.

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

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    I can't see your screencap.

    Sounds like you want something like this...

    Data Range
    A
    B
    C
    D
    1
    ------
    ------
    ------
    ------
    2
    A
    66
    X
    273
    3
    B
    86
    C
    4
    C
    92
    K
    5
    74
    A
    6
    51
    A
    7
    60
    C
    8
    58
    D
    9
    3
    J
    10
    2
    B


    This formula entered in D2:

    =SUMPRODUCT(--ISNUMBER(MATCH(C2:C10,A2:A4,0)),B2:B10)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Tony - works perfectly. Thanks!!

  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: SUMPRODUCT if Fields Match a RANGE of Criteria

    You're welcome. Thanks for the feedback!

  6. #6
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    As a follow up - can anyone tell me how to modify Tony's formula in his 3/5/15 post above to let it use a 2D (versus a 1D) array as the criteria? i.e. in Tony's post on 3/5 above, if the criteria (i.e. A, B and C) spanned two columns and three rows instead of being only in one column and three rows?

  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 if Fields Match a RANGE of Criteria

    Like this...

    Data Range
    A
    B
    C
    D
    E
    1
    ------
    ------
    ------
    ------
    ------
    2
    A
    B
    66
    X
    331
    3
    C
    D
    86
    C
    4
    92
    K
    5
    74
    A
    6
    51
    A
    7
    60
    C
    8
    58
    D
    9
    3
    J
    10
    2
    B


    This formula entered in E2:

    =SUMPRODUCT(SUMIF(D2:D10,A2:B3,C2:C10))

  8. #8
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Perfect!! Thank you!

  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 if Fields Match a RANGE of Criteria

    You're welcome!

  10. #10
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Another follow up question!

    Is it possible to combine the SUMIF method above that Tony posted with additional criteria (i.e. that you would include in the SUMPRODUCT formula using --)

  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 if Fields Match a RANGE of Criteria

    Need more details.

    Maybe post a SMALL sample file (about 20 rows of data is plenty) and show us what result you expect.

  12. #12
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    So cell G5 has the SUMPRODUCT/SUMIF formula you posted previously. I'd like to be able to add another criteria to the formula to only sum rows where there is a "yes" in column F. So the formula should sum cells in Column D for which column E contains A, B, C, or D AND column F contains a "yes". So the final result should be the 197 in H5.
    Attached Files Attached Files

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

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Like this...

    =SUMPRODUCT(SUMIFS(D5:D13,E5:E13,B5:C6,F5:F13,"Yes"))

  14. #14
    Registered User
    Join Date
    03-29-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    Perfect once again. Thank you!

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

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    You're welcome!

  16. #16
    Registered User
    Join Date
    08-24-2016
    Location
    USA
    MS-Off Ver
    2016
    Posts
    12

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    HI,

    I have a follow-up question on above thread. I'm trying to use sumproduct across workbooks, one of them will be closed. Trying to sum a column matching,certain keyword list. Actually, these keywords,
    should be an exclusion. In other words, i would like to sum column with rows which do not include the list of keywords. I would like to maintain keyword list in a column, separately, which will be
    updated from time to time. But I do not want to update rows of sumproduct formulas, every time there is a new keyword.
    I'm not very proficient with VBA, but I would consider VBA code as an option as well.
    Any help is much appreciated.

    here is the formula I have:
    =SUMPRODUCT(--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$E$2:$E$500=A89),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$A$2:$A$500=B89),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Fee"),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Subscription Fee"),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Boat Fee"),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Other"),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Travel"),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>"Serving"),'[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$J$2:$J$500)



    But here is what ideally I would like to have:
    =SUMPRODUCT(--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$E$2:$E$500=A89),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$A$2:$A$500=B89),--('[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$R$2:$R$500<>Keywrods),'[Global Chart 2016 1.1.16.xlsx]Raw Data 2016'!$J$2:$J$500)

    List of keywords would be in separate column:
    Exclusion keywords:
    Fee
    Subscription Fee
    Boat Fee
    Other
    Travel
    serving


    I hope I did not violate any forum rules. If I did, please accept my apologies. Please point out a violation and I'll do my best to comply with the forum policy.

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

    Re: SUMPRODUCT if Fields Match a RANGE of Criteria

    The forum owner prefers that you start your own thread.

    Forum rule #2

+ 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. Count SUMPRODUCT Members / Average of SUMPRODUCT
    By Shingaru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2014, 03:59 PM
  2. Replies: 1
    Last Post: 05-19-2012, 02:54 AM
  3. Replies: 5
    Last Post: 04-20-2012, 08:54 AM
  4. Replies: 6
    Last Post: 03-09-2011, 08:01 AM
  5. Using a SumProduct Count to find a SumProduct Total?
    By XL021710 in forum Excel General
    Replies: 3
    Last Post: 02-18-2010, 08:31 AM

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