+ Reply to Thread
Results 1 to 6 of 6

Converting a number with a specified number of decimal places into a string

  1. #1
    Forum Contributor
    Join Date
    10-10-2015
    Location
    the Dysfunctional Empire of Bulgaria
    MS-Off Ver
    2010
    Posts
    102

    Converting a number with a specified number of decimal places into a string

    I have the number 0.5, I would like to turn it into the string 0.500.

    Or more broadly, I have some function which returns a value ( in this case exactly 0.5), but I want to turn the number into a string and extend the "visible" accuracy to three decimal places.

    For example,

    Please Login or Register  to view this content.
    Now, Range("R8") displays "0.5 0.5" and not "0.500 0.500" which is what I want to display.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Converting a number with a specified number of decimal places into a string

    You need to format the number

    Range("R8").NumberFormat = "0.000"
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Contributor
    Join Date
    10-10-2015
    Location
    the Dysfunctional Empire of Bulgaria
    MS-Off Ver
    2010
    Posts
    102

    Re: Converting a number with a specified number of decimal places into a string

    That does not seem to do it for me.

    I've also tried using the round function to no avail.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Converting a number with a specified number of decimal places into a string

    Maybe:

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 04-21-2016 at 09:13 AM.

  5. #5
    Forum Contributor
    Join Date
    10-10-2015
    Location
    the Dysfunctional Empire of Bulgaria
    MS-Off Ver
    2010
    Posts
    102

    Re: Converting a number with a specified number of decimal places into a string

    Thanks JOHN, that works great.

    How does it work?

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Converting a number with a specified number of decimal places into a string

    You're welcome glad to help out. The format function tells it which format to use and the apostrophe returns the number as text. "'" & Format(YOURCELL VALUE, "0.000"). Thanks for the feedback.

+ 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. [SOLVED] Need to limit the number of decimal places of a number in a text string
    By Turbo Dog in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-11-2013, 07:47 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. Vba to format number of decimal places dependant on number in another cell
    By wonderdunder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2012, 09:33 AM
  5. Replies: 7
    Last Post: 02-07-2011, 01:47 PM
  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. converting number string to number with decimal
    By rortiz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-15-2005, 04:05 PM
  8. 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