Note: The other languages of the website are Google-translated. Back to English

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.


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

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.

2. Then type below formula in a blank cell, in this example, I will enter the formula in cell E2, and then press Ctrl + Shift + Enter keys together, it will return the total value from the list based on the certain text. See screenshot:

=SUM(IF(ISNUMBER(FIND(D2,$B$2:$B$9)),VALUE(LEFT($B$2:$B$9,FIND(D2,$B$2:$B$9)-1)),0))

Note: In the above formula, D2 is the criterion which you want to use, and B2:B9 indicates the cell range you want to sum.

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


Sum cells containing text and numbers based on the certain text with a handy feature

If the above formula is hard for you to understand, Kutools for Excel provids a useful tool - Sum based on the same text, with this feature, you can get the total result within a cell which mixed with numbers and text without remembering any formulas.

Note:To apply these Sum based on the same text features, firstly, you should download the Kutools for Excel, and then apply the features quickly and easily.

After installing Kutools for Excel, please do as follows:

1. Click to select a cell where you want to output the result, see screenshot:

Tips: To prevent circular references, please don’t insert this formula into the first row of the worksheet.

2. And then click Kutools > Formula Helper > Formula Helper, see screenshot:

3. In the Formulas Helper dialog box, please do the following operations:

  • Select Statistical from the Formula Type drop down list;
  • In the Choose a formula list box, click to select Sum based on the same text option;
  • Then, in the Arguments input section, select the range of cells containing the text and numbers that you want to sum in the Range textbox, and then, select the text cell you want to sum values based on in the Text textbox.
Tips: In the Text textbox, you should change the default absolute cell reference to relative cell reference for dragging the formula correctly.

4. And then, click Ok button, the first result will be calculated, then drag the fill handle for fill the formula to other cells, see screenshot:


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?.

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
'Updateby Extendoffice
    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(A2) (A2 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:


More relative articles:

  • Combine Duplicate Rows And Sum The Values In Excel
  • In Excel,you may always meet this problem, when you have a range of data which contains some duplicate entries, and now you want to combine the duplicate data and sum the corresponding values in another column, as following screenshots shown. How could you solve this problem?
  • Multiply Two Columns And Then Sum In Excel
  • In Excel, most of us may suffer to multiply two columns and then add them up, of course, we can multiply each items and then sum them, but this will be troublesome if there are hundreds or thousands rows need to calculate. In Excel, there is a powerful function – SUMPRODUCT, with it, we can quickly multiply two columns and then sum them. This article, I will talk about how to apply this function.
  • Sum Top 3 Or N Values Based On Criteria In Excel
  • Normally, we can sum the top n values from a range of cells by using a simple formula, but have you ever tried to sum top n values based on some criteria. This article, I will introduce some formulas for summing top n values with specific criteria in Excel.
  • Sum Unique Values Based On Criteria In Excel
  • For example, I have a range of data which contains Name and Order columns, now, to sum only unique values in Order column based on the Name column as following screenshot shown. How to solve this task quickly and easily In Excel?
  • Count Or Sum Cells Based On The Font Colors In Excel
  • How could you get the number of cells or sum all the cells which contain a particular font color in Excel? For example, I have a range of data in a worksheet as following screenshot shown, and now I want to respectively count or sum the cells that have a red, blue and black font color. Normally, there is no direct way to deal with this task, here, I will talk about some tricks for soling this job.

The Best Office Productivity Tools

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. 60-day money back guarantee.
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
Comments (44)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
i think you are real teacher and good man. good luck.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
ok, i understood this. good luck.
This comment was minimized by the moderator on the site
The SumNumbers macro saved me many hours of manual work. Thank you!
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
GENUIS.... Thanks ever so much
This comment was minimized by the moderator on the site
How to convert between text and number using KUTOOls ?
This comment was minimized by the moderator on the site
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,
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
How to include decimals in the "=SumNumbers(A1)" formula? Thank you!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
Remember to press Ctrl+Shift+Enter after changing the formula, not just Enter.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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:
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Hello, Giovanni,
Can you give an example of your problem?
You can attach a screenshot here.
Thank you!
This comment was minimized by the moderator on the site
I am also looking to see if this function can sum multiple cells.
This comment was minimized by the moderator on the site
=SumNumbers(D8:AH8)
This comment was minimized by the moderator on the site
Hi,
How to multiply 10 pcs *200,

not 10*200
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations