ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to determine the number? (https://www.excelbanter.com/excel-discussion-misc-queries/201466-how-determine-number.html)

Eric

How to determine the number?
 
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

Don Guillett

How to determine the number?
 
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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
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



Gary''s Student

How to determine the number?
 
=LEFT(A1,1)+RIGHT(A1,1)+MID(A1,2,1)+MID(A1,3,1)
--
Gary''s Student - gsnu200802

Eric

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

"Don Guillett" wrote:

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
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




John C[_2_]

How to determine the number?
 
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.
--
John C


"Eric" wrote:

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


Don Guillett

How to determine the number?
 
Nice

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John C" <johnc@stateofdenial wrote in message
...
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.
--
John C


"Eric" wrote:

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



Roger Govier[_3_]

How to determine the number?
 
Hi Eric

try
=SUMPRODUCT(--MID(A1,ROW(INDIRECT("$1:$"&LEN(A1))),1))
--
Regards
Roger Govier

"Eric" wrote in message
...
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



John C[_2_]

How to determine the number?
 
The absolute references in the INDIRECT statement are unnecessary. :)
--
John C


"Roger Govier" wrote:

Hi Eric

try
=SUMPRODUCT(--MID(A1,ROW(INDIRECT("$1:$"&LEN(A1))),1))
--
Regards
Roger Govier

"Eric" wrote in message
...
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



Roger Govier[_3_]

How to determine the number?
 
Absolutely True
Comes out of habit (and does not cause a problem(bg)

--
Regards
Roger Govier

"John C" <johnc@stateofdenial wrote in message
...
The absolute references in the INDIRECT statement are unnecessary. :)
--
John C


"Roger Govier" wrote:

Hi Eric

try
=SUMPRODUCT(--MID(A1,ROW(INDIRECT("$1:$"&LEN(A1))),1))
--
Regards
Roger Govier

"Eric" wrote in message
...
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




All times are GMT +1. The time now is 04:06 AM.

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