Summing up digits in a cell

  • Thread starter Thread starter Sai Krishna
  • Start date Start date
S

Sai Krishna

Hi,

i need to add all the digits in a cell. For example, if I have a number 58
in a cell, the adjacent cell should return a value of 13.
regards
krishna
 
Try this small UDF:

Function digicount(r As Range) As Integer
Dim n As Integer
digicount = 0
v = r.Value
L = Len(v)
For i = 1 To L
n = Mid(v, i, 1)
digicount = digicount + n
Next
End Function
 
Thanks a ton Brad. Was looking for something as useful and simple as this.
regards
krishna
 
... this has helped for two digits.

Another option for 1-2 digit numbers ...

=A1-9*INT(A1/10)

--
Dana DeLouis
 
Back
Top