Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Sum of digits in a number

Example: a number 1234 would sum individual dighits to a value of 10.

I thought there would be a function in Excel that would do that but can't
seem to find it. I don't want write a macro with MID functions to do the
summing. Is there such a function in Excel?

Thank you in advance for any help
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 367
Default Sum of digits in a number

Hi Bob

there is no direct function, but you could use the following:
=SUMPRODUCT(MID(A1,ROW(INDIRECT("1:" & LEN(A1))),1)*1)

hth

Carlo

On Jan 8, 9:17*am, Bob Ptacek
wrote:
Example: a number 1234 would sum individual dighits to a value of 10.

I thought there would be a function in Excel that would do that but can't
seem to find it. I don't want write a macro with MID functions to do the
summing. Is there such a function in Excel?

Thank you in advance for any help


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Sum of digits in a number

Bob

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

I forget who originally posted this, but well done!


Gord Dibben MS Excel MVP


On Mon, 7 Jan 2008 16:17:02 -0800, Bob Ptacek
wrote:

Example: a number 1234 would sum individual dighits to a value of 10.

I thought there would be a function in Excel that would do that but can't
seem to find it. I don't want write a macro with MID functions to do the
summing. Is there such a function in Excel?

Thank you in advance for any help


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 149
Default Sum of digits in a number

Is there such a function in Excel?
Afaik, no. but simple enough to create.

Public Function StringSum(str As String) As Long
Dim i As Integer
For i = 1 To Len(str)
StringSum = StringSum + Mid(str, i, 1)
Next i
End Function

A1: 1234
B1: =StringSum(A1)
B1 should display 10

--
HTH,
George


"Bob Ptacek" wrote in message
...
Example: a number 1234 would sum individual dighits to a value of 10.

I thought there would be a function in Excel that would do that but can't
seem to find it. I don't want write a macro with MID functions to do the
summing. Is there such a function in Excel?

Thank you in advance for any help



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 return first 3 digits of a number? Curalice Excel Worksheet Functions 3 April 3rd 23 03:45 PM
How to customize number to 10 digits including 2 digits after deci Carina Excel Worksheet Functions 3 September 20th 07 02:50 AM
adding digits of a number dantee Excel Worksheet Functions 8 March 30th 06 11:05 PM
How do I find the sum of all digits in a number? monkeyforce5 Excel Discussion (Misc queries) 4 September 9th 05 09:49 PM
help with removing digits from a number frank Excel Discussion (Misc queries) 4 July 12th 05 02:31 AM


All times are GMT +1. The time now is 11:04 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"