+ Reply to Thread
Results 1 to 9 of 9

Formatting to 2 Decimal Spaces

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Formatting to 2 Decimal Spaces

    So I feel like this should be simple and I've tried multiple different ways of doing this but when I save the information in a text file it still pulls all of the numbers to the right of the decimal place even though it only shows 2 numbers to the right in excel. And the Round function in VBA isn't doing anything it just exits my code or does nothing.

    So I've tried this

    Please Login or Register  to view this content.
    as well as

    Please Login or Register  to view this content.
    and this

    Please Login or Register  to view this content.
    it will show in the cell the number as 389.69 but when you click on it is still has every number beyond the decimal point 389.694864815648946. Does anyone know what I'm missing or is excel not capable of this? Thank you

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Formatting to 2 Decimal Spaces

    389.694864815648946.
    is the mathematical value stored in a number. Try in a calculator, you get the same result

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,743

    Re: Formatting to 2 Decimal Spaces

    Formatting a number in excel only changes the presentation of the number and how it used in calculation presentations. It does not change the value. To get the formatted number to be the actual number, you will need to copy it and do a paste special values
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,436

    Re: Formatting to 2 Decimal Spaces

    Try this:

    Please Login or Register  to view this content.

    I take it they are just values in those cells?

    If they're formulas, you should modify the actual formulas to use Round( ... , 2)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Formatting to 2 Decimal Spaces

    Not to be rude, but yes AB33, I understand how the calculation works, but I don't want it to round.

    Thank you alansidman, the special paste crossed my mind at one point but left just as fast from frustration prbably.

    TMShucks, it's just exiting my code when I do that. There aren't any formulas in that cell because I'm having the code loop through an array to put the values in those cells...would that matter?

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Formatting to 2 Decimal Spaces

    *want it to round...for some reason the edit post isn't letting me actually edit.

  7. #7
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Formatting to 2 Decimal Spaces

    Please Login or Register  to view this content.
    ended up working. Thanks for letting me bounce ideas off you guys.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Formatting to 2 Decimal Spaces

    I was trying to say the same as alansidman's, but did not put the way he did.
    The underlying calculation and value will not change, the formatting will not change the underlying value, but only the presentation.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,436

    Re: Formatting to 2 Decimal Spaces

    I'm having the code loop through an array to put the values in those cells...would that matter?
    I wouldn't know. I've only seen the bit of code you've shared with us. And the reason that doesn't work is because you're mixing VBA with Excel functions and trying to put a line of VBA code into a cell. I suspect that you have error trapping somewhere else that stops it bombing out.

    Regards, TMS
    Last edited by TMS; 09-27-2013 at 12:30 PM.

+ 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. Replies: 1
    Last Post: 05-03-2012, 05:28 PM
  2. [SOLVED] Decimal Formatting in Windows English vs European Formatting
    By Drummer361 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2006, 09:50 AM
  3. [SOLVED] Excel puts spaces after the decimal
    By Isabel in forum Excel General
    Replies: 5
    Last Post: 04-01-2006, 08:35 AM
  4. Phantom spaces after decimal point.
    By sutats in forum Excel General
    Replies: 2
    Last Post: 06-23-2005, 01:12 PM
  5. [SOLVED] decimal spaces toolong when mail merging from excel
    By punkyh in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 04-29-2005, 10:06 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