View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
George Nicholson George Nicholson is offline
external usenet poster
 
Posts: 149
Default Sum of digits in a number

Is there such a function in Excel?
Afaik, no. but simple enough to create.

Public Function StringSum(str As String) As Long
Dim i As Integer
For i = 1 To Len(str)
StringSum = StringSum + Mid(str, i, 1)
Next i
End Function

A1: 1234
B1: =StringSum(A1)
B1 should display 10

--
HTH,
George


"Bob Ptacek" wrote in message
...
Example: a number 1234 would sum individual dighits to a value of 10.

I thought there would be a function in Excel that would do that but can't
seem to find it. I don't want write a macro with MID functions to do the
summing. Is there such a function in Excel?

Thank you in advance for any help