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
ie , interpreted as US based argument delimiter - translated to ;
whereas the latter two both return 1 as both are inserted as
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)
Bookmarks