Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Summing Digits in a Value.

Summing Digits in a Value

by Allen Wyatt
(last updated October 27, 2015)


If you have a cell that contains a value, you may want to devise a way to add together all the digits in the value. For instance, if a cell contains the value 554, you might want to determine the sum of 5+5+4, which is 14.

There are several ways you can approach this task. (Doesn't that always seem the way in Excel?) The first is to use a formula that relies on several functions:


This regular formula will sum the digits in any integer value (in cell A1) in a simple, elegant manner. This is not the only possible formula, however. The following is an array formula (terminated by pressing Ctrl+Shift+Enter) version of the same formula:


Either of these formulas work fine if the value in A1 is a positive whole number. If there are any non-digit characters in the number (such as a negative sign or a decimal point), then the formulas return a #VALUE! error.

These are not the only formulas possible for this type of calculation. You can find some other examples of formulas in the Microsoft Knowledge Base:

You can also use a user-defined function to return the desired sum. The following macro steps through each digit in the referenced cell and calculates a total. This value is then returned to the user:

Function AddDigits(Number As Long) As Integer
    Dim i As Integer
    Dim Sum As Integer
    Dim sNumber As String

    sNumber = CStr(Number)
    For i = 1 To Len(sNumber)
        Sum = Sum + Mid(sNumber, i, 1)
    AddDigits = Sum
End Function

To use this function, just use a formula such as =AddDigits(A1) in a cell. An even more compact user-defined function (invoked in the same manner) is the following:

Function AddDigits(ByVal N As Long) As Integer
    Do While N >= 1
        AddDigits = AddDigits + N Mod 10
        N = Int(N / 10)
End Function

Unlike the earlier macro, this version doesn't convert the cell contents to a string in order to process it. Instead, it steps through each digit of the value, stripping off the last digit and adding it to the total.


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2424) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Summing Digits in a Value.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Positioning Graphics Evenly

If you have some graphics inserted in your document, you may want to adjust the horizontal space between those graphics. ...

Discover More

Converting Strings to Numbers

When working with data in a macro, there are two broad categories you can manipulate: numbers and text. Sometimes you ...

Discover More

Quickly Copying Formatting

Need to quickly copy formatting from one area to another in your document? Docs makes it easy through the Paint Format tool.

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Counting Jobs Completed On a Date

When you store the date and time in a single cell, it can be a bit confusing to count how many cells contain a particular ...

Discover More

Formulas Don't Calculate as Formulas

Enter a formula (starting with an equal sign) and you may be surprised if Excel doesn't calculate the formula. Here's a ...

Discover More

Complex Lookup Formulas

If you need to combine information in some of your cells in order to produce a result needed to, in turn, look up other ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 9 - 6?

2018-05-07 14:36:38


The link to

Returned a Page Not Found error....

2018-04-05 17:16:54


Dear Sir,

can you please help me to undestand this formula, functions. Because this only give digits sum but i need digits sum in a single digit. And i also want to do some more things with this. Please sir help me to find solution of this issue.


2018-02-21 00:21:59


I have Some digit or Value in particular 1 cell Ex. 153

I expect answer is 153 means 1+5+3 = 9

How to do total with formula particular in 1 Cell

2017-05-11 10:57:09

Deshaun M Montgomery

Thank you for the simplistic answers. I have a similar challenge in a workbook. I am using a combination of Concatenate and Filter to return a string of numbers from one sheet to another into a single cell. I then need to sum the string so that I have a total for each filter criteria. The equations you provide work great until trying to sum numbers that are two digits such as "10,10" which displays as 1010 in the cell. I require a sum of 20 but receive a sum of 2. Is there any way around that.


2017-01-09 15:06:53

Thomas Blanchard

Wow--it works! thank you!

2016-08-06 23:08:36


If possible you can help me in writing a formula for the following:





2016-01-26 00:02:09


Hi there,

I'm experiencing trouble with having too large of numbers for Excel to handle. To give you an example, I need Excel to handle a number such as the following without rounding it off:

Number I need - > 0.00000067055225372314453125 - > Sum of all digits = 72
Excel Outputs - > 0.00000067055225372314500000 - > Sum of all digits = 56

Excel rounds off digits which skews my data by a lot because I need to have the sum of all digits of the entire number.

I need 2 things:

1. 0.00000067055225372314453125 / 2 - > simply to be able to divide a large format number such as this one by 2 and get the actual result by somehow manipulating it to be in text format. It needs to be a text format to begin with, treat it as a number and divide it by 2 then convert back to text format so that all the digits actually exist.

2. Then I need to get the sum of all the digits of the result in one particular cell that unfortunately has to be formatted as text in order to have all the digits.

This would be easier if the cell was formatted as a number, but the number ends up too large for excel to handle so my result ends up wrong.

I hope this makes sense :)

Thanks so much in advanced,

2015-04-12 12:45:36

Willy Vanhaelen

Here is a user defined function that works with negative numbers and numbers with decimals as well:

Function AddDigits(Number As String) As Integer
Dim i As Integer, Char As String
For i = 1 To Len(Number)
Char = Mid(Number, i, 1)
If IsNumeric(Char) Then AddDigits = AddDigits + Char
End Function

2015-04-11 06:18:13


Many thanks for this. I absolutely love playing with Excel and it is nice to know that when I get stuck there is an amazingly clever person like you out there to come to my rescue. Formula worked perfectly.

2013-05-14 09:25:59



As this tip says, it is for Excel 97 through Excel 2003. If you want to see how it works in Excel 2010, click the link at the end of the tip which says "You can find a version of this tip for the ribbon interface..."


2013-05-13 11:20:27

Tzvetin Kmeski


My Excel version is 2010 and unfortunately this tip doesn't work.

How this tip will looks for excel 2010?



2013-01-10 06:46:25



Thanks for this, Excellent one.

I would like to explore withing the same formula, how can we get the result to one single digit or reduce to one single digit.


2012-12-26 06:31:39

Keith Griffiths

From website:

there is this formula for producing sums of digits in a value:


However I would like to multiply the digits of the value within a cell. i.e. if A1 is 456 a formula would produce 120. I recognize that a zero digit would make the result zero so the formula would have to ignore zeros. to get the result of the remaining non-zero digits.

Would appreciate any ideas.

2012-08-22 13:23:12

Rick Rothstein

There is a one-liner UDF (user defined function) that can do this...

Function DigitSum(S As String) As Long
DigitSum = Evaluate(Replace(StrConv(S, vbUnicode), Chr(0), "+") & "0")
End Function

Obviously, large "numbers" have to be formatted as text. The function will successfully handle a text string of up to 127 digits.

@Armando and Houdini,

That UDF and those formulas do not do the same thing as the UDF that Allen posted... Allen's UDF (and the one I posted above) sums the digits whereas as yours do a "casting out 9's" summation of digits... they are not the same thing.

2012-08-11 08:17:19

Armando Montes

Check this out:
Function Quick(ByVal number)
Quick = (number - 1) Mod 9 + 1
End Function
Same as formula

That formula works for me but note that it will fail for values of A1 greater than 1207959552 (because MOD function returns an error in that case)
This version can cope with larger numbers

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.