+ Reply to Thread
Results 1 to 10 of 10

Decimal moving and values lost when converting from string

  1. #1
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Decimal moving and values lost when converting from string

    Hi All

    This is driving me mad, I'm hoping I someone can help.

    I have written a script that re-formats a data set; part of it takes a text string, removes the leading characters and then displays the remaining numbers. I had just left it as text but it now needs to be shown as a value with 2 decimal places.........this is where the problems started.......

    When I convert to a value it drops the decimal values.

    I am in the UK on a UK machine but the script is for a user in the Netherlands. I have changed the location settings on my machine and am using Dutch formatted data to test.

    I have put an example of what is happening is below,

    Starting Value: AUD29.442,72

    After this script: (where c is each cell in a given range) (I have selected each cell as it seemed to be the only way to get it to show as a number.)

    Please Login or Register  to view this content.

    Resulting Value: 29,442

    Just wondering if anyone can either spot something I have done wrong or suggest a resolution.

    Thanks in advance

    Cheers

    Jim
    Last edited by JimmyA; 11-28-2012 at 04:59 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Decimal moving and values lost when converting from string

    what's the rest of the code?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Decimal moving and values lost when converting from string

    You could try this, if you don't mind the result as text
    =RIGHT(A1,LEN(A1)-3)
    Click on star (*) below if this helps

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Decimal moving and values lost when converting from string

    Please Login or Register  to view this content.
    i think its because
    Please Login or Register  to view this content.
    is text


    however
    AUD29.442,72
    is supposed to resolve to what?
    Please Login or Register  to view this content.
    gives
    29.44272

  5. #5
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Decimal moving and values lost when converting from string

    Hi K m

    Thanks but I used to have it formatted as text but it now needs to be a value and that is where the problem has started.

    Hi martindwilson

    This is the rest of the code for the column
    Please Login or Register  to view this content.
    Thanks

    Jim

  6. #6
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Decimal moving and values lost when converting from string

    Thanks martindwilson

    The value should show

    29.442,72

    In the Netherlands they have full stops as separators and commas as the decimal.

    My Laptop has been set to Dutch settings so I was expecting it to show correctly.

    Any ideas?

    Thanks again

    Jim

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Decimal moving and values lost when converting from string

    Please Login or Register  to view this content.
    should work then
    i changed my regional settings and i get
    29.442,72
    Last edited by martindwilson; 11-28-2012 at 04:46 PM.

  8. #8
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Decimal moving and values lost when converting from string

    Hi Jimmy,

    I read your post and tried some other approach :D
    Works for me and my dutch excel.
    Code is also capable of working with more then 2 decimals as the source, and more or less chars at the start.

    Please Login or Register  to view this content.
    Last edited by rkey; 11-28-2012 at 04:51 PM. Reason: decreased the code a bit.

  9. #9
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Decimal moving and values lost when converting from string

    Boom!! Thank you very much Martin

    That looks to have sorted it!!

    Thanks again

    Jim

  10. #10
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Decimal moving and values lost when converting from string

    Hi rkey

    Sorry I'm a bit slow on the typing.

    Thanks very much for your help, I will take a look at this too.

    Cheers

    Jim

+ 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