Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How to determine the number?

=LEFT(A1,1)+RIGHT(A1,1)+MID(A1,2,1)+MID(A1,3,1)
--
Gary''s Student - gsnu200802
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,358
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default 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


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,358
Default 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


  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine the number of types? Eric Excel Discussion (Misc queries) 5 March 17th 08 12:00 PM
Determine Row number JMay Excel Discussion (Misc queries) 3 July 3rd 07 01:40 PM
How to determine the cell contain number only? Eric Excel Discussion (Misc queries) 1 July 2nd 07 09:28 AM
How to determine the number in excel? Eric Excel Discussion (Misc queries) 1 March 13th 06 06:32 AM
Determine number of days Jack Excel Worksheet Functions 1 January 10th 06 01:34 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"