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.
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.
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.
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
Do While Number >= 1
SumDigits = SumDigits + Number Mod 10
Number = Int(Number / 10)
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.
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.
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 !
How to sum diagonal of a range in Excel?
Recommended Productivity Tools
Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings
300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for
1500+ work scenarios, helps you solve
82% Excel problems.
- Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
- Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
- Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
- No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
- Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
- 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
- Change the way you work now, and give you a better life immediately!
- Increases your productivity by
50% when viewing and editing multiple documents.
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Open and create documents in new tabs of same window, rather than in new windows.
- Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!