Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
stevo
 
Posts: n/a
Default Adding digits in a single cell


Is it possible to total the number of digits in a single cell? e.g. if a
cell contains the number 23456 can you put a maths function in another
cell to display the total i.e 20? Many thanks.


--
stevo
------------------------------------------------------------------------
stevo's Profile: http://www.excelforum.com/member.php...o&userid=10737
View this thread: http://www.excelforum.com/showthread...hreadid=512178

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Adding digits in a single cell

Here you go

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

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"stevo" wrote in
message ...

Is it possible to total the number of digits in a single cell? e.g. if a
cell contains the number 23456 can you put a maths function in another
cell to display the total i.e 20? Many thanks.


--
stevo
------------------------------------------------------------------------
stevo's Profile:

http://www.excelforum.com/member.php...o&userid=10737
View this thread: http://www.excelforum.com/showthread...hreadid=512178



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
broro183
 
Posts: n/a
Default Adding digits in a single cell


Hi Stevo,

I've just adapted this from a user defined function (UDF) that sorts
the digits in a cell
(http://www.excelforum.com/showthread.php?t=507991).

To use this UDF, press [alt + F11], [ctrl + R], go to Insert - Module,
& paste the following in:


Function sum_digits(s As String) As Long
Application.Volatile 'This forces the function to update
Dim i As Long
For i = 1 To Len(s)
sum_digits = sum_digits + Mid(s, i, 1)
Next i
End Function

Now, if your # (eg 23456) that you want to sum is in A1, enter
"=sum_digits(A1)" into cell B2 & you should see 20 appear in cell B1.


For more tips/background & a link see:
http://www.excelforum.com/showthread.php?t=507919, &
http://www.excelforum.com/showthread...ion.Vola tile


hth,
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=512178

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
Color a single digit in a mult-digit number cell Phyllis Excel Discussion (Misc queries) 6 November 17th 05 12:46 AM
Formula and Data Entry in a Single Cell Josh VM Excel Discussion (Misc queries) 1 October 21st 05 09:31 PM
Adding a Single Cell total from Seperate sheets GccTxs Excel Worksheet Functions 3 October 3rd 05 11:57 AM
adding zero's to a text cell Jennifer Excel Worksheet Functions 2 August 13th 05 02:54 AM
adding a formula in a cell but when cell = 0 cell is blank Mike T Excel Worksheet Functions 5 May 31st 05 01:08 AM


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