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

doc-sum-digits-9

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!



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:

doc-sum-digits-1

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.

doc-sum-digits-1

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.


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:

doc-sum-digits-1

4. Then drag the fill handle down to the cells that you want to contain this formula, you will get the following result.

doc-sum-digits-1

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.


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:

doc-sum-digits-1

3. In the Formula Helper dialog box, click doc-sum-digits-1 button to select the cell value that you want to sum the digits, see screenshot:

doc-sum-digits-1

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:

doc-sum-digits-1

Download and free trial Kutools for Excel Now !


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?


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

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!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • 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!
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.
    yun · 5 months ago
    Before i ask i apologize about some rude and hard -to-understand expressions which could be in follow sentences caused by my poor English skill in advance.

    Thanks. It was helpful.
    I could use this functions and solve the problem though, I actually couldn't get how the function work.

    This is the function :
    =SUM(1*MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))

    I know functions "SUM", "MID", "ROW", and "INDIRECT", but I have no idea about expressions "1*MID" and ""1:"&" at all.

    Can someone give me any answer or clue which can make me understand?
  • To post as a guest, your comment is unpublished.
    Birzhan · 9 months ago
    Hi,
    your formula is very useful.
    but I need to have a one number at the end, but your formula is giving two numbers.
    can you help?
    regards
  • To post as a guest, your comment is unpublished.
    panjianom · 9 months ago
    Great code!
    How to repeat the process into 1 digit with VBA code?
    Example: 463 > 4+6+3=13 > 1+3=4
  • To post as a guest, your comment is unpublished.
    Pranam Shriyan · 11 months ago
    In same way how do i multiply
    i have some excel numbers like Exm : 445, 556 , 713 . ( 4*4*5 ) i want multiplication of this
    thnx
    • To post as a guest, your comment is unpublished.
      skyyang · 11 months ago
      Hi, Shriyan,
      To multiply all numbers within a cell, you can apply the following user defined function:


      Function MultiplyDigits(ByVal Number As Long) As Long
      'Update 20140905
      MultiplyDigits = 1
      Do While Number >= 1
      MultiplyDigits = MultiplyDigits * (Number Mod 10)
      Number = Int(Number / 10)
      Loop
      End Function

      And then apply this formula: =MultiplyDigits(A2)

      Please try it, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Tongle · 1 years ago
    This is not all possible permutations. If I put 123, how can I get the 27 permutations. That means, including 111 etc.