+ Reply to Thread
Results 1 to 6 of 6

Count Zeros after comma

  1. #1
    Registered User
    Join Date
    10-28-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    30

    Count Zeros after comma

    Hi,

    How can I count the number of zeros after comma
    I mean

    0.000406 has 3 zeros
    0.376556 has 0 zeros
    0.000000434005 has 6 zeros

    Thanks

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Count Zeros after comma

    Hi, Try thid UDF
    Right click Sheet Tab , Select "View Code". Vb Window appears.
    From the VB Toolbar select "Insert", "Module". (New window appears.
    Paste code into Blank Window.
    Close VB window.
    To run Function enter in cell as :-
    Please Login or Register  to view this content.
    For string in "A1".
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,535

    Re: Count Zeros after comma

    Perhaps (assuming values are valid Excel numbers)

    =MAX(0,ROUNDUP(-LOG(A1,10),0)-1)

    where A1 etc hold decimal values.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Count Zeros after comma

    Following on from DonkeOte's very neat idea ,how about:-
    To include Decimal Number greater than 1
    Please Login or Register  to view this content.
    Mick

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,535

    Re: Count Zeros after comma

    Mick, I'm not sure that would work given base 10 decimals - eg 1.01
    (why I used ROUNDUP and -1)

    A few alternatives for handling numbers >= 1 .. one might be:

    =IF(MOD(A1,1),ROUNDUP(-LOG(ROUND(MOD(A1,1),15)),0)-1,0)

    No doubt the above can be shortened (assumes 15 digit significance) ... but has added pre-emptive MOD test.

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Count Zeros after comma

    DonkeyOte,
    I think you've cracked it now , nice solution
    Regards Mick

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1