+ Reply to Thread
Results 1 to 8 of 8

Sumif with an array as the criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    03-02-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Sumif with an array as the criteria

    Hi,

    Would really appreciate if someone could help me out with a problem I'm having.

    If, say, I had a formula like this: SUM(SUMIF(E1:E10,{102,1733,2927,3500},F1:F10)) The criteria is an array. Now if I wanted to use a reference instead of a hard coded array inside the formula, how would I go about it.

    I tried different things something like putting the array in a separate cell and referring to it inside the formula but nothing would work.

    i.e. SUM(SUMIF(E1:E10,indirect(H1),F1:F10))

    The reason I use the array is that the number of criteria in the criteria field varies, from one to 11 between rows, so this solution is the simplest in my view but I can't get it to work.

    The criteria looks like this
    154
    247,265
    311
    322,356,364,378,399,400
    412
    413,414,416
    etc, etc.

    Thanks in advance

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

    Re: Sumif with an array as the criteria

    could you give them a named range?
    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
    03-02-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Sumif with an array as the criteria

    I tried but it didn't work. Plus the formula needs to be copied down, since the the summarization should be done for each criteria record, meaning that each criteria cell needs to have a separate name?

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

    Re: Sumif with an array as the criteria

    Quote Originally Posted by ValGlad View Post
    The criteria looks like this
    154
    247,265
    311
    322,356,364,378,399,400
    412
    413,414,416
    etc, etc.
    Are the comma separated values in the same cells or is every number in a separate cell?
    Audere est facere

  5. #5
    Registered User
    Join Date
    03-02-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Sumif with an array as the criteria

    To daddylonglegs


    In the same cell
    Last edited by ValGlad; 01-15-2013 at 05:39 PM.

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

    Re: Sumif with an array as the criteria

    In that "criteria" range all the numbers are 3 digits - is that always true? Are the numbers in E1:E10 all 3 digit numbers too?

    Assuming the criteria is in H1:H6 try this "array formula"

    =SUM(ISNUMBER(SEARCH(","&E1:E10&",",","&TRANSPOSE(H1:H6)&","))*F1:F10)

    confirmed with CTRL+SHIFT+ENTER
    Last edited by daddylonglegs; 01-15-2013 at 06:07 PM.

  7. #7
    Registered User
    Join Date
    03-02-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Sumif with an array as the criteria

    Quote Originally Posted by daddylonglegs View Post
    In that "criteria" range all the numbers are 3 digits - is that always true? Are the numbers in E1:E10 all 3 digit numbers too?

    Assuming the criteria is in H1:H6 try this "array formula"

    =SUM(ISNUMBER(SEARCH(","&E1:E10&",",","&TRANSPOSE(H1:H6)&","))*F1:F10)

    confirmed with CTRL+SHIFT+ENTER
    The numbers in H1:H10 could be 3 or 4 digits, the numbers in E1:E10 are the same - 3 or 4 digits, it's always a single number.

    I couldn't get your formula to work:
    E1:E4 F1:F4 H1:H4 (CRITERIA) Formula Result
    2699 1 351,1733,2699,845 4444
    351 10 351,1733,2699,845 4444
    1733 100 351,1733,2699,845 4444
    845 1000 351,1733,2699,845 4444
    Attached Files Attached Files
    Last edited by ValGlad; 01-15-2013 at 06:51 PM.

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

    Re: Sumif with an array as the criteria

    OK, you put the formula in 4 rows? Are you expecting one result for each row of H1:H4.......or a single result for the whole thing?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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