+ Reply to Thread
Results 1 to 5 of 5

Decimal Sign Replaced with ; Sign

Hybrid View

  1. #1
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Decimal Sign Replaced with ; Sign

    VBA is heavily american-ised hence the issue.

    When you write a comma back to native XL using .Formula XL when "translating" will interpret that as an American argument delimiter hence this is subsequently translated to ; natively in your locale.

    As you say by changing the , to . using the standard Formula based approach XL when translating interprets that as a decimal delimiter (US) and it is thus subsequently translated back to your locale specific decimal delimiter - the comma.

    On the other hand the FormulaLocal property won't conduct any translation of your formula string - the string will be literally inserted as requested without alteration.

    A quick way to illustrate on your own client would be the following:

    Sub Example
    Dim dblValue As Double: dblValue = "29,2"
    Cells(1,"A").Formula = "=IF(" & dblValue & ",1)"
    Cells(2,"A").FormulaLocal = "IF(" & dblValue & ";1)"
    Cells(3,"A").Formula = "=IF(" & Replace(dblValue,",",".") & ",1)"
    End Sub
    You will find the first example returns 2 as the formula translates into

    =IF(29;2;1)
    ie , interpreted as US based argument delimiter - translated to ;

    whereas the latter two both return 1 as both are inserted as

    =IF(29,2;1)
    FormulaLocal - no translation of string

    Formula Replace method - US based decimal delimiter (.) translated to locale specific delimiter (,)

    Which approach you adopt is obviously down to your own personal preference.... though of course if you have thousand separators (.) in your values the Formula Replace method becomes further convoluted (ie 2 replace calls required - in correct order)
    Last edited by DonkeyOte; 12-10-2009 at 08:48 AM. Reason: added final note re: thousands separator

  2. #2
    Registered User
    Join Date
    11-23-2009
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Decimal Sign Replaced with ; Sign

    DonkeyOte,
    Thanks for the extended explanation and methods to solve this problem. I'm going to tag this thread in hope it helps others with the same problem. This took me a lot of time :D

+ 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