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 cells with text and numbers in Excel?

For example, I have a list of values containing numerical and textual strings, now, I want to sum only the numbers based on the same text, look at the following screenshot. Normally, you can’t sum the values in the list with text string directly, here, I will introduce you some formulas to deal with this task.


Split / Separate text strings into individual text and number columns:

Kutools for Excel’s Split Cells feature is a powerful tool, it can help you to split cell values into multiple columns or rows, it can help you to slit alphanumeric strings into separated text and numbers columns, etc…

doc sum text number 8

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!


Sum cells containing text and numbers based on the certain text with formula


Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

You can use an array formula to sum the numbers based on their corresponding text string within the cell, please do as follows:

1. First you can write down your text strings you want to sum the relative numbers in a column cells.

doc sum text number 2

2. Then type below formula in a blank cell, in this example, I will enter the formula in cell E1: =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)), and then press Ctrl + Shift + Enter keys together, it will return the total value from the list based on the certain text. See screenshot:

doc sum text number 3

Tip: In the above formula, D1 is the criterion which you want to use, and B2:B8 indicates the cell range you want to sum.

3. Then select the formula cel, and drag the fill handle down to the cells you want to apply this formula to get the result:

doc sum text number 4


Sum cells containing text and numbers ignoring the text with User Defined Function


If you have the following data which is mixed with text and numbers, and you just want to extract and add up only the numbers in each cell, how could you quickly finish this in Excel?.

doc sum text number 5

To deal with this problem, you can create a User Defined Function, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: sum only the numbers in the cell containing numbers and text

Function SumNumbers(rngS As Range, Optional strDelim As String = " ") As Double
'Update 20141210
    Dim xNums As Variant, lngNum As Long
    xNums = Split(rngS, strDelim)
    For lngNum = LBound(xNums) To UBound(xNums) Step 1
        SumNumbers = SumNumbers + Val(xNums(lngNum))
    Next lngNum
End Function

3. Then save and close this code, go back to the worksheet, and enter this formula =SumNumbers(A1) (A1 indicates the cell you want to sum up the numbers), then drag the fill handle down to the cells you want to fill the formula, and only numbers in each cell are added together, see screenshot:

doc sum text number 6


Sum all individual numbers within a cell

Sum all individual numbers within a cell

If you want to add up all numbers within a cell, Kutools for Excel’s Sum numbers in a cell can help you quickly sum all digits of a number together in a cell.

doc sum text number 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!


Related articles:

How to sum every n rows down in Excel?

How to sum values based on text criteria 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.
    Z · 15 days ago
    If you have the following data which is mixed with text and numbers, and you just want to extract and add up only the numbers in each cell, how could you quickly finish this in Excel?.

    Bro, but I only want to sum specific number after specific word? can I do that?
  • To post as a guest, your comment is unpublished.
    Yuri · 5 months ago
    Thank you very much!!!
  • To post as a guest, your comment is unpublished.
    jasmeet · 8 months ago
    In this formula =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)) can be put a range in place of D1 - say D1:D5 - not getting result, if i put it this way. What is the correct way to do this?
  • To post as a guest, your comment is unpublished.
    NP · 9 months ago
    Hi, I want to be able to add a number and also text to one cell (C5 all the way to C16) then get only the numbers in there to add up. But the =SumNumbers(A1) formula doesn't seem to work.
  • To post as a guest, your comment is unpublished.
    Emmy du Plooy · 1 years ago
    Hi, I hope someone can help. I like to add inside the cell +100j+50f+600m but must display/add on cell as 750 only. So you see 750 in cell but when press F2, it will show =100j+50f+600m
  • To post as a guest, your comment is unpublished.
    David · 1 years ago
    Hi. Please can someone help me. I am trying to SUM a column in EXCEL that has numbers and letters. eg 8.1km, 10.5km etc. There are 1031 lines or cells in the column. I am using this formula =SUM(LEFT(D3),LEN(D3)-2+LEFT(D4),LEN(D4)-2) which works if i want to add 2 or 3 cells together but i cant use this for 1031 cells. i wanted to add a : in place of the + but it comes back with an error and will not allow me to create the formula. Any help will be greatly appreciated
  • To post as a guest, your comment is unpublished.
    Mrityunjay · 1 years ago
    Hi,
    How to multiply 10 pcs *200,

    not 10*200
  • To post as a guest, your comment is unpublished.
    Giovanni · 1 years ago
    Hi,

    Thank you for this post! I am keen on using the VBA code and I was thinking if it would be possible to have a multivariable function so that you can sum the numbers from different column cells and write something like SumNumbers(A1:C1), for example.


    Many Thanks


    Giovanni
  • To post as a guest, your comment is unpublished.
    Anna · 2 years ago
    hi can anyone help me how to add below numbers with letters? i tried to do like but it doest work i think i miss something in the formula=SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)). please help.Thanks.

    2L
    5D
    10S
    3L
    11D
    16S
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hello, Anna,
      First, you should extract the letters into another helper column, and then apply the above formula, after entering this formula, please remember to press Shift + Ctrl + Enter keys together. see the following screenshot image:
  • To post as a guest, your comment is unpublished.
    JudyW · 2 years ago
    Hi There! I have two types of numbers in one column, one is numeric numbers, the other is a character followed by a number (such as n20, n30, etc). I wish to add up those numbers with an "n". I applied your guidance for "Sum Cells Containing Text And Numbers Based On The Certain Text With Formula", but it did not work. Is there any other method? Thanks in advance!
  • To post as a guest, your comment is unpublished.
    Ravi Sharma · 2 years ago
    April May June July Total
    1100 / 65658 1200/65657 1500/65656 2100/65650 ?

    i want to total only 1100+1200+1500+2100
    Other not a value only Receipt no. please help any
  • To post as a guest, your comment is unpublished.
    Ravi Sharma · 2 years ago
    How To Sum of selected word in cell in excel

    Exam

    1100/656480

    1100 is a amount and 656480 is recpt. no. but i want to total only 1100
  • To post as a guest, your comment is unpublished.
    Laura · 2 years ago
    Hello,
    The =SUM(IF(ISNUMBER(FIND(D1,$B$2:$B$8)),VALUE(LEFT($B$2:$B$8,FIND(D1,$B$2:$B$8)-1)),0)) - worked perfectly, except that my text is on the right.
    I tried to change the formula however that is not working... i just keep getting #VALUE!

    Can anyone help?
    • To post as a guest, your comment is unpublished.
      LeRoy · 2 years ago
      Remember to press Ctrl+Shift+Enter after changing the formula, not just Enter.
  • To post as a guest, your comment is unpublished.
    Colt · 2 years ago
    Can anyone help me with a sum formula?
    I'm trying to sum a column with cells that contain both numbers and text.
    I want to sum the numbers to the left of the text letter. sample:
    3P30
    2P30
    2P30
    2P30
    1P20
    3P30
    1P20
    3P50
    3P30
    3P60
  • To post as a guest, your comment is unpublished.
    Angela · 2 years ago
    How to include decimals in the "=SumNumbers(A1)" formula?
    Thank you!
  • To post as a guest, your comment is unpublished.
    Gil Michael Regalado · 2 years ago
    Here's a simple script that accepts single dimension and 2 dimensional selection range of cells with each cell containing string or numbers but with each cell reduced to single numbers and returns the sum of all cells.


    Option Explicit

    Function SUMCELLS(InputRange As Range) As Double
    Dim Arr() As Variant
    Arr = InputRange
    Dim R As Long
    Dim C As Long
    SUMCELLS = 0

    For R = 1 To UBound(Arr, 1) ' First array dimension is rows.
    For C = 1 To UBound(Arr, 2) ' Second array dimension is columns.
    Debug.Print Arr(R, C)
    Dim NumericValue As Double
    Dim StringValue As String

    StringValue = Trim(CStr(Arr(R, C)))
    If (Not (StringValue = "")) Then
    NumericValue = ONLYDIGITS(StringValue)
    SUMCELLS = SUMCELLS + NumericValue
    End If
    Next C
    Next R
    End Function

    Function ONLYDIGITS(s As String) As String
    Dim retval As String
    Dim i As Integer

    Dim periods As Integer
    periods = 0

    retval = ""
    '
    For i = 1 To Len(s)
    Dim char As String
    char = Mid(s, i, 1)
    If (char >= "0" And char
  • To post as a guest, your comment is unpublished.
    Kimberly Koester · 2 years ago
    I was able to use this formula perfectly, but I would also like to add a condition to only include certain numbers in the SUM formula if the value in another column = "defects".

    My original formula (using your original post) is:
    =SUM(IF(ISNUMBER(FIND("hrs",E17:E38)),VALUE(LEFT(E17:E38,FIND("hrs",E17:E38)-1)),0))

    Where E17:E38 contains the text and numbers that I want to sum
    And B17:B38 contains the values "features" and "defects"

    How can I adjust the formula to only SUM those numbers in column E if the value in column B = "defects"?

    Thanks in advance!

    Kimberly,
  • To post as a guest, your comment is unpublished.
    fazlul haque · 2 years ago
    How to convert between text and number using KUTOOls ?
  • To post as a guest, your comment is unpublished.
    MIKE · 2 years ago
    GENUIS.... Thanks ever so much
  • To post as a guest, your comment is unpublished.
    Jenny · 3 years ago
    This is super helpful! I'm trying to get the ARRAY to work with a column of cells that each contains a decimal number and text (e.g. .2 A; .5 C; .1 X etc), and I keep getting a result of 0. If I change the numbers to whole numbers, the result is correct. Help?
  • To post as a guest, your comment is unpublished.
    kc · 3 years ago
    is the any way to rewrite the vba code to sum multi cells instead of one? I have about 8 columns of data and i want the sum at the end.
  • To post as a guest, your comment is unpublished.
    Paul Burchfield · 3 years ago
    Is it possible to change the SumNumbers formula to add all the numbers in a column of mixed cells? For example, each column has 1A, 2B, 3C and I would like the formula at the bottom of the column to tell me 6.
  • To post as a guest, your comment is unpublished.
    Madelene · 3 years ago
    The SumNumbers macro saved me many hours of manual work. Thank you!
  • To post as a guest, your comment is unpublished.
    sadekul islam · 4 years ago
    ok, i understood this. good luck.
  • To post as a guest, your comment is unpublished.
    tawhid · 4 years ago
    In A1 Cell of excel I input data as like 5+6+3+1-2
    And A2 Cell of excel give the Result 13
    how it possible in excel.
  • To post as a guest, your comment is unpublished.
    sadekul islam · 4 years ago
    i think you are real teacher and good man. good luck.