+ Reply to Thread
Results 1 to 5 of 5

get number instead of string when using Format(x, "#,##0.00")

  1. #1
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Question get number instead of string when using Format(x, "#,##0.00")

    Hi,


    I'm using the following code.

    Please Login or Register  to view this content.
    When I look at the generated file I see that the cell is left aligned and there is an exclamation saying that the number has been saved as text.
    This is obviously not what I want.

    I checked the format function and it seems to return a string.
    Is there a way to make sure it returns a number.


    Thanks
    Last edited by gosa; 12-06-2011 at 10:22 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: get number instead of string when using Format(x, "#,##0.00")

    Change the cell format instead:
    Please Login or Register  to view this content.
    I assume you are aware that the VBA Round function does not work the same way as the worksheet version. (it uses Bankers Rounding)
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: get number instead of string when using Format(x, "#,##0.00")

    Quote Originally Posted by romperstomper View Post
    Change the cell format instead:
    Please Login or Register  to view this content.
    I assume you are aware that the VBA Round function does not work the same way as the worksheet version. (it uses Bankers Rounding)
    Hi,

    Thanks. The numberformat is showing up correctly.

    Also thanks for the headsup. I don't want the use the Bankers Rounding.
    Luckaly you've got eagle eye's.
    Should I be using the following instead?

    Please Login or Register  to view this content.

    Thanks.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: get number instead of string when using Format(x, "#,##0.00")

    Yes - that will give you 'normal' rounding.

  5. #5
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: get number instead of string when using Format(x, "#,##0.00")

    Great!
    I really wouldn't have known if you didn't mention it.
    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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