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.
![](http://cdn.extendoffice.com/images/stories/doc-excel/sum-with-text-and-numbers/doc-sum-number-with-text-1.png)
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:
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.
After installing Kutools for Excel, please do as follows:
1. Click to select a cell where you want to output the result, see screenshot:
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.
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.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
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!