count of digit in a number

J

Jim Thomlinson

You can use this formula. It counts the number of digits for the number in
cell A1. Note that it counts the number of digits entered, not the number of
digits displayed. for instance if the number is formatted to show 2 decimals
and the number 5 is enetered, the cell will show 5.00, but since only 1 digit
was entered the formula will return 1...

=IF(ISERROR(FIND(".",A1)), LEN(ABS(A1)), LEN(ABS(A1))-1)

also I assume you don't count the decimal as a digit, nor the negative sign.
 
R

RB Smissaert

You will have to be careful with that:

Sub test()

Dim d As Double

d = 100
MsgBox Len(d)

End Sub

May have to do:
MsgBox Len(CStr(d))


RBS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top