+ Reply to Thread
Results 1 to 3 of 3

Adusting decimal places based on greatest number of places in a series

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    1

    Adusting decimal places based on greatest number of places in a series

    Hi all,

    I'm trying to figure out a way to dynamically set the number of decimal places for a cell based on the number in a given series that has the greatest number of decimals. For example if I have:

    100
    125.78964
    120.22
    133.768
    178.9

    the result I'm trying to get is:

    100.00000
    125.78964
    120.22000
    133.76800
    178.90000

    Because one of the numbers goes to 5 places, all the numbers go to 5 places. If the number with the most decimals had only two places, all of the numbers would have two places.

    I have a function that counts the number of decimal places in a given number, and then a simple MAX formula to get the largest number, but am stuck on how I can change the number of decimal places based on that result.

    Any help would be appreciated!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Adusting decimal places based on greatest number of places in a series

    best i can come up with is this array entered formula
    ="0."&REPT(0,MAX(0,LEN(ROUND(A$1:$A$5-INT($A$1:$A$1:A5),8))-2)) in say d1
    then with numbers in a1
    in b1
    =TEXT(A1,$D$1)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    08-25-2011
    Location
    Norco, Ca
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adusting decimal places based on greatest number of places in a series

    Martin,

    I'm not sure if you are still on this forum, but your answer on here would do pretty much what I am looking for. I just don't know how to apply it to my spreadsheet. Could you explain how I woudl apply this to a range of cells?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy number with 3 or more decimal places and paste the actual value as 2 decimal number
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-29-2013, 12:57 AM
  2. number of decimal places
    By Geordie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-22-2010, 03:06 AM
  3. Paste two decimal number in excel without extra decimal places appearing
    By jeffery_frick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2009, 07:49 PM
  4. limit my number to 2 decimal places
    By Eee in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 12-19-2007, 09:12 AM
  5. Converting a number to 2 decimal places
    By mattslav in forum Excel General
    Replies: 2
    Last Post: 06-03-2005, 11:10 PM

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