+ Reply to Thread
Results 1 to 3 of 3

Sumif + Sumif?

  1. #1
    Registered User
    Join Date
    03-29-2005
    Posts
    1

    Sumif + Sumif?

    Say I have a worksheet containing the following values:

    A B
    ------
    1 | A 5
    2 | B 4
    3 | C 7
    4 | A 3
    5 | C 2
    6 | B 1


    What function can I use to sum the values in column B if the value in column A = "A" or "B"? The only way I can think of is to use SUMIF(A:A,"=A",B:B) + SUMIF (A:A,"=B",B:B). But in my real worksheet A could contain about 15 different text strings that I want to sum the corresponding values for, so that is a lot of SUMIF's. I have played around with SUMPRODUCT but without success.

    Thanks.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996
    Regarding your example, this would work:

    =SUM(IF(ISERROR(FIND(A1:A6,"~A~B",1)),0,B1:B6))

    Note: Since that is an array formula, you must commit it by holding down the Control and Shift keys when you press Enter.

    I separated the individual values with tildes (~) so an entry of "AB" wouldn't trigger a match.

    See if that helps.

    Regards,
    Ron

  3. #3
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try...

    =SUMPRODUCT(--(ISNUMBER(MATCH(A1:A6,{"A","B"},0))),B1:B6)

    OR

    =SUMPRODUCT(--(ISNUMBER(MATCH(A1:A6,D1:D2,0))),B1:B6)

    ...where D1:D2 contain your text values.

    Hope this helps!

+ 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