+ Reply to Thread
Results 1 to 7 of 7

Decimal Places

  1. #1
    Forum Contributor
    Join Date
    10-25-2012
    Location
    Honolulu, Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    128

    Decimal Places

    Hello to all and thank you for taking time to read this.

    I have a simple formula that calculates 9 places to the right of the decimal point. Is there anyway to calculate only 2 places to the right of the decimal point without using the ROUND function ?

    I ask this question because it takes ions to calculate several dozen worksheets with 10's of thousands of rows. If I only have 2 decimal places; i.e. 10.23 instead of 10.239870985 it would speed up the time it takes to compute the final answer.

    I created a separate macro to round the answer to 2 decimal places and it takes foreverrrrrrrrrrrr. There must be an easier way.

    Please Login or Register  to view this content.
    Aloha To All
    Last edited by rmccain; 07-23-2016 at 01:52 PM.

  2. #2
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: Decimal Places

    Do not write the formula, just calculate in the code
    for example
    Please Login or Register  to view this content.
    even faster if to work with arrays and not with cells
    To do it for me and help me it is 2 different things!
    Sorry for my english, blame Google translator

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Decimal Places

    You'd better protect the calculation by testing the B2 value!

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Decimal Places

    Quote Originally Posted by rmccain View Post
    I have a simple formula that calculates 9 places to the right of the decimal point. Is there anyway to calculate only 2 places to the right of the decimal point without using the ROUND function ?

    I ask this question because it takes ions to calculate several dozen worksheets with 10's of thousands of rows. If I only have 2 decimal places; i.e. 10.23 instead of 10.239870985 it would speed up the time it takes to compute the final answer.
    I created a separate macro to round the answer to 2 decimal places and it takes foreverrrrrrrrrrrr.
    It does not take any more "ions" to calculate with many decimal places than to calculate with 2 decimal places.

    I assume you mean that it takes extra CPU cycles to explicitly round formulas so the result is always 2 decimal places.

    And yes, that can be very costly if you rely on event macros to adjust the calculation after-the-fact instead of using the Excel ROUND function.

    (Of course, the Excel ROUND does also add CPU time. But not nearly as much as an event macro would.)

    The only alternative is to set the option "Precision as displayed". But there are many reasons why many of us deprecate its use.

    Caveat: If you choose to try setting PAD, be sure to make a copy of the Excel file first. Setting PAD can unintentionally change constants irreversibly.

    Some of the many concerns about PAD:

    1. "Precision as displayed" is a misnomer. It should be "Precision as formatted". The distinction is: if the cell is formatted as General and Excel chooses to display a result with only 2 decimal places, the actual underlying value might still have more decimal places, even if PAD is set. We must explicitly format cells with a specific number of decimal places in order for PAD to behave as intended.

    2. PAD only applies to the final numeric result of a cell. So, for example, IF(10.1 - 10 = 0.1, TRUE) still returns FALSE(!).

    3. PAD applies to all cells in all worksheets in a workbook. Consequently, setting PAD might affect other formulas unexpectedly, especially in non-active or hidden worksheets. If you set PAD after implementing a very complex workbook, it would behoove you to review every formula and cell format to be sure the results are what you intended.

    4. PAD might change constants irreversibly. Suppose you want to enter an interest rate as Percentage with 6 decimal places for accuracy, but you format it as Percentage with 2 decimal places for readability. You cannot do that, if PAD is already set. And if you enter the accurate interest rate, then set PAD (or apply the format), the interest rate is changed permanently. That might affect directly and indirectly dependent calculations throughout the workbook.

    5. When PAD is set, merely changing a cell's format (appearance) can unintentionally impact calculations in directly and indirectly dependent cells throughout the workbook.

    Be that as it may, only you can weigh the risks of setting PAD and concomitant workbook-wide review with the effort to change "dozens" of worksheets with "10s of thousands" of rows.

    As difficult as that might seem, often it is possible to insert the requisite ROUND functions, with due consideration, by selecting a range of cells, modifying the first formula, then pressing ctrl-Enter (not ctrl-shift-Enter) instead of Enter in order to propagate the change throughout the range.

    Nevertheless, I agree that it can be a daunting task as an after-thought for such a complex workbook.
    Last edited by joeu2004; 07-24-2016 at 01:24 AM. Reason: cosmetic

  5. #5
    Forum Contributor
    Join Date
    10-25-2012
    Location
    Honolulu, Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    128

    Re: Decimal Places

    Thank you for your reply.

    Very interesting and I have read about this but not with a great explanation like yours. May, I ask you this;

    I am running an i7 3610QM with 16GB of RAM . I also start the task manager and look at the processing power and it is not maxing out; it is maybe at 25% . Is there any other solutions ?

    Thankyou Again

  6. #6
    Forum Contributor
    Join Date
    10-25-2012
    Location
    Honolulu, Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    128

    Re: Decimal Places

    Aha you are right , I was trying to figure out what the code was for this !!!

    Thankyou .

  7. #7
    Forum Contributor
    Join Date
    10-25-2012
    Location
    Honolulu, Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    128

    Re: Decimal Places

    This is the actual code if I use the example above it will not calculate the cells independently. Every cells in A and B have different values.

    LR = .Range("A" & .Rows.Count).End(xlUp).Row
    .Range("C2").Formula = "=(A2-B2)/ B2 * 100"
    .Range("C2:L" & LR).FillDown

    Thankyou

+ 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. Adusting decimal places based on greatest number of places in a series
    By anelson87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2022, 01:05 PM
  2. Replies: 2
    Last Post: 12-29-2013, 08:37 PM
  3. [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
  4. [SOLVED] Calculating decimal places in a non decimal format (ie sixes not tens)
    By Mike Brewer in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-07-2013, 08:58 AM
  5. Replies: 4
    Last Post: 12-26-2012, 05:37 AM
  6. 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
  7. Replies: 4
    Last Post: 06-10-2009, 12:50 PM
  8. [SOLVED] FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT.
    By SUKYKITTY in forum Excel General
    Replies: 3
    Last Post: 07-06-2005, 09:05 AM

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