+ Reply to Thread
Results 1 to 11 of 11

VBA - decimal separator issue

  1. #1
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6

    VBA - decimal separator issue

    Hi,
    I have a list, where in one column there are values with "." as decimal delimiter.
    All values are formatted as Text.
    As I am in Germany and the decimal delimiter of my system is "," so I want to change all these values to numbers with the "," as decimal delimiter.
    When I open the file only some of the cells get the warning, that there is a number formatted as text. It seems totally random.

    But now I tried several solutions replacing the "." with a "," but in those cells, where I see this Excel warning with the wrong format, all attemps end up with wrong numbers.

    Before:
    2022-11-30_14-55-57.png

    After:
    2022-11-30_14-59-27.png

    I tried

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    or to change from text to number:
    Please Login or Register  to view this content.
    All of theme result in the same issue, that only these numbers with apparantly wrong format (the ones with the small green arrow in the corner) have then wrong values.
    For example the value in the 4th row should be "6,7908" after the change and not "67908".

    Can someone point me in the right direction?

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,275

    Re: VBA - decimal separator issue

    Get the data from the columns to the array variable and process with the "Val" function - copy the data from the variable back to the sheet, but before re-copy do formatting the columns to the "General" format.

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA - decimal separator issue

    I know sometimes to get text cells to turn into number cells you have to do a math problem with them.
    There are two ways that I know of, just add zero to the number or multiply by one.
    Without a sample sheet I can't tell you how to do it but maybe format another column as numbers and then use a formula referring to the cells showing as text and multiple the reference by 1 or add 0, whatever is your preference.
    You could then change those formulas to values and paste them back into the original cell.
    I would just try one cell that's an issue first not all of them.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA - decimal separator issue


    Hi,

    or just using Cell.Formula = Cell.Value …

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: VBA - decimal separator issue

    Hello. A re-question, StingerMKO: is this information obtained after "copying and pasting" from the internet?...

    I ask you because, in addition to what you can often see, there is a character (160) that looks like the space character (32) but is not the same and complicates the normalization of those numbers.

    I also suggest that you upload a workbook to the Forum with several of these numbers to better analyze them.
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  6. #6
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6

    Re: VBA - decimal separator issue

    Thanks, I will try these suggestions and let you know.

  7. #7
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6
    Quote Originally Posted by beyond Excel View Post
    Hello. A re-question, StingerMKO: is this information obtained after "copying and pasting" from the internet?...

    I ask you because, in addition to what you can often see, there is a character (160) that looks like the space character (32) but is not the same and complicates the normalization of those numbers.

    I also suggest that you upload a workbook to the Forum with several of these numbers to better analyze them.
    Alright, will do if none of the above mentioned tips work

  8. #8
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6

    Re: VBA - decimal separator issue

    Quote Originally Posted by Marc L View Post

    Hi,

    or just using Cell.Formula = Cell.Value …

    This did not work, 0*Value of the cell results in the same value and same issue after switching from "." to ","
    Last edited by StingerMKO; 12-01-2022 at 04:09 AM.

  9. #9
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6

    Re: VBA - decimal separator issue

    Quote Originally Posted by skywriter View Post
    I know sometimes to get text cells to turn into number cells you have to do a math problem with them.
    There are two ways that I know of, just add zero to the number or multiply by one.
    Without a sample sheet I can't tell you how to do it but maybe format another column as numbers and then use a formula referring to the cells showing as text and multiple the reference by 1 or add 0, whatever is your preference.
    You could then change those formulas to values and paste them back into the original cell.
    I would just try one cell that's an issue first not all of them.
    This also did not work, same value/issue after this.
    Last edited by StingerMKO; 12-01-2022 at 04:09 AM.

  10. #10
    Registered User
    Join Date
    10-13-2014
    Location
    Germany
    MS-Off Ver
    Office 2007
    Posts
    6

    Re: VBA - decimal separator issue

    Quote Originally Posted by mjr veverka View Post
    Get the data from the columns to the array variable and process with the "Val" function - copy the data from the variable back to the sheet, but before re-copy do formatting the columns to the "General" format.

    This finally did the trick and now all the numbers are automatically in the correct decimal format with "," as deliminter. Thank you!
    Last edited by StingerMKO; 12-01-2022 at 04:10 AM.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA - decimal separator issue


    Quote Originally Posted by StingerMKO View Post
    This did not work, 0*Value of the cell results in the same value and same issue after switching from "." to ","
    So you misread as it works like this since last century ! …

+ 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. Convert Number with comma as decimal separator to a decimal
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-20-2020, 08:35 AM
  2. [SOLVED] Autofilter does not work properly - Issue with Comma/Dot decimal separator
    By lucas.lobo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2018, 08:01 AM
  3. [SOLVED] Weird decimal separator issue
    By joebanana in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-29-2012, 04:05 PM
  4. Getting decimal separator
    By Helge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2011, 08:23 AM
  5. Decimal vs. Thousands Separator
    By nsv in forum Excel General
    Replies: 5
    Last Post: 12-28-2010, 06:05 AM
  6. IE8.0 & EXCEL Decimal Separator Issue.
    By littlelittle in forum Excel General
    Replies: 0
    Last Post: 08-07-2009, 12:41 PM
  7. How to change decimal separator . to ,
    By MG in forum Excel General
    Replies: 2
    Last Post: 03-03-2006, 08:45 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