ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   urgent : count of digits in a number (https://www.excelbanter.com/excel-programming/359875-urgent-count-digits-number.html)

Shira

urgent : count of digits in a number
 
i need a function or a macro that calculates the count of digits in a number



Die_Another_Day

urgent : count of digits in a number
 
Like....

Function CountDigits(ByVal Number as integer) as integer
CountDigits = Len(Number)
End Function

Or did I miss something?

Die_Another_Day


Mark Lincoln

urgent : count of digits in a number
 
If your number is in A1, then:

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

This checks for a decimal point and adjusts accordingly. If the cell
will always contain a whole number, just use:

=LEN(A1)


Niek Otten

urgent : count of digits in a number
 
=LEN(A1)
This includes any decimal separator. It also counts a single zero if the value is <1.

--
Kind regards,

Niek Otten


"SHIRA" wrote in message ...
|i need a function or a macro that calculates the count of digits in a number
|
|



AA2e72E

urgent : count of digits in a number
 
This function calculates the length of a number:

Function NLength(ByVal MyNum As Double) As Integer
Select Case Sgn(MyNum)
Case Is = 1
NLength = 1 + Int(Log(MyNum) / Log(10))
Case Is = 0
NLength = 1
Case Is = -1
NLength = 2 + Int(Log(Abs(MyNum)) / Log(10))
End Select
End Function

HOWEVER, this omits the fractional part: if you know the precision to which
you want to show the number, add 1 + the number of digits after the decimal
point to the result.


"SHIRA" wrote:

i need a function or a macro that calculates the count of digits in a number




All times are GMT +1. The time now is 12:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com