+ Reply to Thread
Results 1 to 9 of 9

number to text but with only two decimal places

  1. #1
    Registered User
    Join Date
    11-25-2003
    Location
    Decatur, Alabama
    Posts
    94

    number to text but with only two decimal places

    I have a spreadsheet where, in column D, is a listing of numbers. Some of the values are whole dollars, some are dollars and cents, and still others are dollars a fractional cents. Here is a simple listing of some of the numbers:

    1306.7
    150.1702
    932.4683
    1110.37
    1212.7652

    I would like to find a macro that will "clean up" my numbers by doing the following: 1) convert all numbers to dollars and cents with always only two decimals places 2) convert these numbers (currently in the general format) to text format instead.

    Thank you very much (in advance) for your help,
    Mike
    Last edited by mjwillyone; 03-10-2009 at 11:59 AM. Reason: SOLVED
    Learn to Serve Others. Kindness is far better than the alternative.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: number to text but with only two decimal places

    Hi,

    Probably not the most elegant, but,

    Please Login or Register  to view this content.
    Will perform the requested operations on the selected cells.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166

    Re: number to text but with only two decimal places

    look at using the cast operators. For example, CINT will cast a value to an integer. Likewise you cant CSTR(value) to cast a value to a string. To get your format you can use

    Please Login or Register  to view this content.
    Last edited by Tarball; 03-09-2009 at 01:45 PM.
    Reach me at excel_help at bellsouth dot net

  4. #4
    Registered User
    Join Date
    11-25-2003
    Location
    Decatur, Alabama
    Posts
    94

    Re: number to text but with only two decimal places

    Sweep,

    Thanks for the quick help! I am getting an error in the following line:

    cl.Value = Round(cl.Value, 2)

    The error I am getting is "Run-time error '13': type mismatch"

    Can you help?

    Thanks,
    Mike

  5. #5
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: number to text but with only two decimal places

    That error is generated if the value of the cell is not numerical.

    Try this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-25-2003
    Location
    Decatur, Alabama
    Posts
    94

    Re: number to text but with only two decimal places

    Dear Dave,

    Thanks for your help. While I still received an error, even after I changed the attributes of the cells to number format, I decided to take your original posted answer and confined the process to just those cells that had a value.

    Please Login or Register  to view this content.
    It works very well. Thank you so much.

    Mike

  7. #7
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: number to text but with only two decimal places

    Glad to help. Could you mark the OP as SOLVED please?

  8. #8
    Registered User
    Join Date
    11-25-2003
    Location
    Decatur, Alabama
    Posts
    94

    Re: number to text but with only two decimal places

    I would love to .. but no edit button appears in the original post. I thought I had already marked it SOLVED by using edit already. However, I am new to this process. Still learning.

    Mike

  9. #9
    Registered User
    Join Date
    07-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: number to text but with only two decimal places

    Hi guys,

    I need to do exactly the same thing (convert numbers to text whilst ensuring I have two decimal places). I have converted the numbers to text and used '&' formula to add the currency symbol. However I end up with various decimal places.... Unfortunately I have no macro knowledge so the above solutions mean nothing to me. Can you help?

    Many thanks

    Lorraine

+ 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