Sum all integers of a given number

P

pchr

Hi,
Is there an easy way to arrange a formula that will Sum all integers
of a given number?

such that when applied on colum A, the result will be B:


21 3
77 14
12345 15
1 1
321 6


thanks for you help,
pchr
 
G

gordon.moar

Hi,
Is there an easy way to arrange a formula that will Sum all integers
of a given number?

Cross posting is a no-no, but on the assumption you may still be
waiting for an answer, here is one way to do it.

Sub sumNumbers()
Dim checkRow As Long
Dim instrPosition As Integer
Dim summedTotal As Long
checkRow = 1
Do
summedTotal = 0
For instrPosition = 1 To Len(Range("a" & checkRow).Value)
summedTotal = summedTotal + _
Mid(Range("a" & checkRow).Value, instrPosition, 1)
Next
Range("B" & checkRow).Value = summedTotal
checkRow = checkRow + 1
Loop Until Range("a" & checkRow).Value = ""
End Sub
 
B

Bob Phillips

=SUMPRODUCT(--(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top