How to determine the number?

E

Eric

Does anyone have any suggestions on how to determine the number?
For example, 2584 in cell A1, then it should return 2+5+8+4=19 in cell B1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric
 
D

Don Guillett

Try this
Sub addupnumberdigits()
ac = ActiveCell
mysum = 0
For i = 1 To Len(ac)
mysum = mysum + Mid(ac, i, 1)
Next i
MsgBox mysum
End Sub
 
E

Eric

Thank everyone for any suggestions
Could you please tell me how to apply following codes?
Thanks you very much for any suggestions
Eric
 
J

John C

Here is a non-vba, non character length specific possibility. Assuming your
value is in cell A1:

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

Hope this helps.
 

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