Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to sum values based on text criteria in Excel?

In Excel, have you ever tried to sum values based on another column of text criteria? For example, I have a range of data in worksheet as following screenshot shown, now, I want to add up all the numbers in column B corresponding with the text values in column A that meet a certain criterion, such as sum the numbers if the cells in column A contains KTE.

doc-sum-based-on-text-1

Sum the values based on another column if contains certain text

Sum the values based on another column if starts with certain text

Sum the values based on another column if ends with certain text

Sum the values based on another column if only is certain text


Advanced Combine Rows:(Combine duplicate rows and sum / average corresponding values):
  • 1. Specify the key column that you want to combine other column based on;
  • 2. Choose one calculation for your combined data.
  • doc-sum-columns-one-criteria-7

    Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


    arrow blue right bubble Sum the values based on another column if contains certain text


    Let’s take the above data for example, to add all the values together which contains the text “KTE” in column A, the following formula may help you:

    Please enter this formula =SUMIF(A2:A6,"*KTE*",B2:B6) into a blank cell, and press Enter key, then all the numbers in column B where the corresponding cell in column A contains text “KTE” will add up. See screenshots:

    doc-sum-based-on-text-2
    -1
    doc-sum-based-on-text-3

    Tip: In the above formula, A2:A6 is the data range which you add the values based on, *KTE* stands for the criteria you need, and B2:B6 is the range you want to sum.


    arrow blue right bubble Sum the values based on another column if starts with certain text

    If you just want to sum the cell values in column B where the corresponding cell in column A which text starts with “KTE”, you can apply this formula: =SUMIF(A2:A6,"KTE*",B2:B6), see screenshots:

    doc-sum-based-on-text-4
    -1
    doc-sum-based-on-text-5

    Tip: In the above formula, A2:A6 is the data range which you add the values based on, KTE* stands for the criterion you need, and B2:B6 is the range you want to sum.


    arrow blue right bubble Sum the values based on another column if ends with certain text

    To add up all the values in column B where the corresponding cell in column A which text ends with “KTE”, this formula can do you a favor: =SUMIF(A2:A6,"*KTE",B2:B6), (A2:A6 is the data range which you add the values based on, KTE* stands for the criterion you need, and B2:B6 is the range you want to sum)see screenshots:

    doc-sum-based-on-text-6
    -1
    doc-sum-based-on-text-7

    arrow blue right bubble Sum the values based on another column if only is certain text

    If you just want to sum the values in column B which corresponding cell content only is “KTE” of column A, please use this formula: =SUMIF(A2:A6,"KTE",B2:B6), (A2:A6 is the data range which you add the values based on, KTE stands for the criterion you need, and B2:B6 is the range you want to sum) and then only the text is “KTE” in column A which relative number in column B will add up, see screenshots:

    doc-sum-based-on-text-8
    -1
    doc-sum-based-on-text-9

    Related articles:

    How to sum every n rows down in Excel?

    How to sum cells with text and numbers in Excel?


    Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

    • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
    • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
    • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
    • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
    • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
    • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
    • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
    • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
    • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
    kte tab 201905

    Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

    • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
    • Open and create multiple documents in new tabs of the same window, rather than in new windows.
    • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
    officetab bottom
    Say something here...
    symbols left.
    You are guest ( Sign Up? )
    or post as a guest, but your post won't be published automatically.
    Loading comment... The comment will be refreshed after 00:00.
    • To post as a guest, your comment is unpublished.
      Chanikya Nadh Desu · 5 months ago
      I create a dynamic string which contains the cells to sum and pass this string to sum function and it gives me #value error. Any solution to this.
      • To post as a guest, your comment is unpublished.
        skyyang · 4 months ago
        Hi, Desu,
        Could you give your problem more detailed, thank you!
    • To post as a guest, your comment is unpublished.
      Paige · 6 months ago
      By the way, I’m using the =SUMIF(A2:A6,"*KTE*",B2:B6) formula, and I want to do more than just the B column (up to column AM).
      • To post as a guest, your comment is unpublished.
        skyyang · 4 months ago
        Hello, Paige,
        For solving your problem, may be there is no simple formula, you should join the SUMIF function together to get the result as you need, for example, you can use the below formula: (you can add other columns data with combining the sumif function)

        =SUM(SUMIF(A2:A6,"*kte*",B2:B6), SUMIF(A2:A6,"*kte*",C2:C6), SUMIF(A2:A6,"*kte*",D2:D6))

        Please try it, hope it can help you!
    • To post as a guest, your comment is unpublished.
      Paige · 6 months ago
      This works but what if I want to use the last part of the formula to cover multiple columns instead of just one?
    • To post as a guest, your comment is unpublished.
      Jordan · 1 years ago
      how do I use a sumif in the following. If a certain cell contains the values of an substring of data, than sum a nearby column. for example, Cell A1 has (Dan,Tom,Bill,Smith). Then a separate table has Dan - 2, Bill - 3, John - 4. Assuming that is a 2x3 table. I want to create a formula that can sum the Dan and Bill numbers (2+3) because those texts could be found in cell A1. So the total would return 5.
    • To post as a guest, your comment is unpublished.
      Lisa Matusiak · 1 years ago
      How do you us sumif formula to with two criteria? For instance, If Column A = X and Column C = C then Sum Column G.
    • To post as a guest, your comment is unpublished.
      Lucky Arora · 1 years ago
      Hi, any one here is having an idea of how to calculate value containing in a cell (Or with text?
      For Example: in Cell A= MR134 , B= MR143, C = MR187 and result will be like sum of 134+143+187 =?
      • To post as a guest, your comment is unpublished.
        Zahirul · 7 months ago
        I am looking for this solution too.
        • To post as a guest, your comment is unpublished.
          skyyang · 7 months ago
          Hello, guys,
          May be the below array formula can help you: (after typing the formula, please press Ctrl+Shift+Enter together)
          =SUM(IF(ISNUMBER(SEARCH("MR",B1:B4)),SUBSTITUTE(B1:B4,"MR",""))+0)
          Please change the cell references to your need.
    • To post as a guest, your comment is unpublished.
      Hector · 1 years ago
      This is super clear and understandable, thank you so much!!!
    • To post as a guest, your comment is unpublished.
      Tom · 2 years ago
      This was super helpful :)
    • To post as a guest, your comment is unpublished.
      JOHN · 2 years ago
      hOW WOULD THIS WORK IF YOU WANTED TO SUM CELLS WITH TEXT THAT CONTAIN KTE & KTO
      • To post as a guest, your comment is unpublished.
        Shay · 1 years ago
        I'm not sure if you mean cells with two different things written in them or cells that say one thing AND cells that say another but for the second case, I just tried this and I wrote it as two separates pieces added together so it could look something like this:
        =(SUMIF(E:E,"*KTE*",D:D) + SUMIF(E:E,"*KTO*",D:D))
    • To post as a guest, your comment is unpublished.
      manoj singh · 3 years ago
      i am insert the sumif formula with correct ranges but it is not showing the sum of numeric values. only showing result 0. Actually some of cells contains text ( i.e.- with ajay, with sonu etc.)
      kindly help for the issue.
    • To post as a guest, your comment is unpublished.
      bassem · 3 years ago
      i want to make sumifs formula from range . but the sum range is formatted text