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: www.excelforum.com/member.php...oamp;userid=10737
View this thread: www.excelforum.com/showthread...hreadid=512178Here you go
=SUMPRODUCT(--(MID(A1,ROW(INDIRECT(quot;1:quot;amp;LEN(A1))),1)))
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
quot;stevoquot; gt; wrote in
message ...
gt;
gt; Is it possible to total the number of digits in a single cell? e.g. if a
gt; cell contains the number 23456 can you put a maths function in another
gt; cell to display the total i.e 20? Many thanks.
gt;
gt;
gt; --
gt; stevo
gt; ------------------------------------------------------------------------
gt; stevo's Profile:
www.excelforum.com/member.php...oamp;userid=10737
gt; View this thread: www.excelforum.com/showthread...hreadid=512178
gt;
Hi Stevo,
I've just adapted this from a user defined function (UDF) that sorts
the digits in a cell
(www.excelforum.com/showthread.php?t=507991).
To use this UDF, press [alt F11], [ctrl R], go to Insert - Module,
amp; 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
quot;=sum_digits(A1)quot; into cell B2 amp; you should see 20 appear in cell B1.For more tips/background amp; a link see:
www.excelforum.com/showthread.php?t=507919, amp;
www.excelforum.com/showthread...ion.Vola tilehth,
Rob Brockett
NZ
Always learning amp; the best way to learn is to experience...--
broro183
------------------------------------------------------------------------
broro183's Profile: www.excelforum.com/member.php...oamp;userid=30068
View this thread: www.excelforum.com/showthread...hreadid=512178
- Nov 21 Wed 2007 20:40
Adding digits in a single cell
close
全站熱搜
留言列表
發表留言
留言列表

