How to sum all digits in a number in Excel?
If you have a cell which contains a value, and now, you want to add all the digits together of the cell. For example, if you have the value 12345 in a cell, you want to do this calculation: 1+2+3+4+5, and get the value 15. Are there any good ways for you to sum all digits of a number in Excel?
Sum all digits in a numbers with formulas
Sum all digits in a numbers with User Defined Function
Sum all digits in a numbers with Kutools for Excel
Sum all individual numbers within a cell:
With Kutools for Excel’s Sum numbers in a cell formula, you can quickly sum all digits of a number together in a cell. 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 all digits in a numbers with formulas
Without adding the digits one by one manually, the following formulas can help you get the summation of a cell quickly.
1. Please enter this formula =SUMPRODUCT(1*MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))(A2 contains the number which you want to sum its digits, you can change it to your need) into a blank cell beside your data, in this example, I will enter it in cell B2. See screenshot:
2. Then press Enter key to return the result, and select the cell B2, then drag the fill handle over to the range that you want to apply this formula, and you will get the summation of digits of each cell number.
Notes:
1. Except the above formula, you can also use an array formula: =SUM(1*MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)), and remember to press Ctrl + Shift + Enter keys together to get the correct result.
2. These formulas work fine if the number is a positive whole number. If there is negative sign or a decimal point in the number, the formulas return a #VALUE! error.
Sum all digits in a numbers with User Defined Function
To add up all digits of a cell number, the following VBA code also can help you.
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Sum all digits of a cell number
Function SumDigits(ByVal Number As Long) As Long 'Update 20140905 Do While Number >= 1 SumDigits = SumDigits + Number Mod 10 Number = Int(Number / 10) Loop End Function
3. Then save and close this code, return to the worksheet, and enter this formula =SumDigits(A2) into a blank cell, see screenshot:
4. Then drag the fill handle down to the cells that you want to contain this formula, you will get the following result.
Notes:
1. If the digit of your number longer or equal 11, you will get an error value.
2. If the number contain negative sign, the result will be zero; if the number contain decimal point, the result will be wrong.
Sum all digits in a numbers with Kutools for Excel
Here, I can also talk about a useful tool- Kutools for Excel, with its Sum numbers in a cell function, you can quickly add up all digits within a number.
Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. |
After installing Kutools for Excel, please do as follows:
1. Click a blank cell where you want to output the result.
2. Then click Kutools > Formulas > Sum numbers in a cell, see screenshot:
3. In the Formula Helper dialog box, click button to select the cell value that you want to sum the digits, see screenshot:
4. Then click Ok button, and drag the fill handle over to the cells that you want to sum the digits in the cells. And all the digits in each cell have been added together, see screenshot:
Download and free trial Kutools for Excel Now !
Demo: Sum all digits in a numbers with Kutools for Excel
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 article:
How to sum diagonal of a range in Excel?
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.
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!