+ Reply to Thread
Results 1 to 7 of 7

Sumif() and Sumifs() Issue/Question

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    Sumif() and Sumifs() Issue/Question

    Hi All,

    This is my first post and I have a question regarding the technical feasibility of this request:

    Can I use the Sumif() or Sumifs() formula to add things together by not the whole cell but just the last two pieces of text in the field? Example:

    QuestionFormn.xlsx

    I need to do it in one formula and cant add any other columns. is this possible? The real example I am using is several hundred lines long, so just selecting and adding is not an option.

    Id appreciate the help

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

    Re: Sumif() and Sumifs() Issue/Question

    One way...

    =SUM(SUMIFS(C3:C11,B3:B11,{"*10","*12"}))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Sumif() and Sumifs() Issue/Question

    Another way (Array formula: must use CNTRL SHFT ENTER to enter. If done properly, you'll see {} around formula)

    =SUM(IF(RIGHT(B3:B11,2)="10",C3:C11)+IF(RIGHT(B3:B11,2)="12",C3:C11))
    Although I prefer Tony's way.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,252

    Re: Sumif() and Sumifs() Issue/Question

    In this case you can use SUMIF rather than SUMIFS.

    =SUM(SUMIF(B3:B11,{"*10","*12"},C3:C11))
    Hope that helps,

    Colin

    RAD Excel Blog

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Sumif() and Sumifs() Issue/Question

    Thanks Tony and everyone else that replied! It worked like a charm!

    I do have a question involving the logic behind the formula. The array potion {"*XXX","*XYX"} is doing what exactly? Is it looking for any cell within the array that contains either XXX or XYX, or is it looking only at the last characters?

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,252

    Re: Sumif() and Sumifs() Issue/Question

    The * is a wildcard which represents one or more characters. So "*10" will check for anything which ends with "10". That could be "a10" or "hello10" or "10". It's important to note that it will only work when the cells contain strings (text), so it wouldn't count a cell which contains the number type 10010, but it would work if the cell contains the string type "10010".

    You might want to have a read through a blog post I did a while back which explains pretty much everything you'll ever want to know about SUMIF:
    http://colinlegg.wordpress.com/2012/...umif-formulas/

  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: Sumif() and Sumifs() Issue/Question

    Quote Originally Posted by Consagrado View Post
    Thanks Tony and everyone else that replied! It worked like a charm!
    You're welcome. Thanks for the feedback!

+ 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