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
Gaurav - 21 May 2008 13:41 GMT
If you only have 2 digits, try this
=SUM(LEFT(A2,1),RIGHT(A2,1))
> 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
Sai Krishna - 22 May 2008 05:36 GMT
Thanks gaurav, this has helped for two digits.
regards
krishna
> If you only have 2 digits, try this
>
[quoted text clipped - 6 lines]
> > regards
> > krishna
Dana DeLouis - 23 May 2008 02:49 GMT
> ... this has helped for two digits.
Another option for 1-2 digit numbers ...
=A1-9*INT(A1/10)

Signature
Dana DeLouis
> Thanks gaurav, this has helped for two digits.
> regards
[quoted text clipped - 10 lines]
>> > regards
>> > krishna
Gary''s Student - 21 May 2008 13:45 GMT
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

Signature
Gary''s Student - gsnu200787
> 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
Brad - 21 May 2008 14:06 GMT
=SUMPRODUCT(--MID(A4,ROW($A$1:INDEX($A:$A,LEN(A4),1)),1))

Signature
Wag more, bark less
> 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
Sai Krishna - 22 May 2008 05:38 GMT
Thanks a ton Brad. Was looking for something as useful and simple as this.
regards
krishna
> =SUMPRODUCT(--MID(A4,ROW($A$1:INDEX($A:$A,LEN(A4),1)),1))
>
[quoted text clipped - 4 lines]
> > regards
> > krishna
Brad - 22 May 2008 13:46 GMT
You're welcome

Signature
Wag more, bark less
> Thanks a ton Brad. Was looking for something as useful and simple as this.
> regards
[quoted text clipped - 8 lines]
> > > regards
> > > krishna