ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum all integers of a given number (https://www.excelbanter.com/excel-programming/390985-sum-all-integers-given-number.html)

pchr

Sum all integers of a given number
 
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


PCLIVE

Sum all integers of a given number
 
Please don't post the same question in multiple Groups.

Regards,
Paul

"pchr" wrote in message
oups.com...
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




[email protected]

Sum all integers of a given number
 
On 8 Jun, 15:41, pchr wrote:
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

--
juux



Bob Phillips

Sum all integers of a given number
 
=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)

"pchr" wrote in message
oups.com...
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




JMB

Sum all integers of a given number
 
Cross posting is okay, multi-posting is irritating.

" wrote:

On 8 Jun, 15:41, pchr wrote:
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

--
juux





All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com