Once approach might be to switch to
Note you would then use ; delimiter etc in your formula string as you would natively, eg:![]()
.FormulaLocal
![]()
.FormulaLocal = "IF(AND(A1=1;A2=2);""x"";""y"")"
Once approach might be to switch to
Note you would then use ; delimiter etc in your formula string as you would natively, eg:![]()
.FormulaLocal
![]()
.FormulaLocal = "IF(AND(A1=1;A2=2);""x"";""y"")"
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
DonkeyOte and chrns12, thanks for the suggestions.
chrns12 wrote me this:
I have worked this out like this.Not sure if this would do it, but try putting a forward slash in front of the comma between the quotes.
Example: "/,"
Depending on what you are working with it tells VBA to take the comma literally. Since it's getting converted to a semicolon I'm assuming that the comma has a special meaning within the syntax you are working with.
Let me know if that worked.
First i have declared the variable as string:
Then i used replace like this:![]()
Public STD As String
This as solved my problem.![]()
STD = Replace(STD, ",", ".")
I think this is a big fault for non English language excel because VBA will always convert signs and some of them totally change the meaning of variables (like the decimal sign).
Thanks again for your suggestions.
Regards
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:
You will find the first example returns 2 as the formula translates into![]()
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
ie , interpreted as US based argument delimiter - translated to ;![]()
=IF(29;2;1)
whereas the latter two both return 1 as both are inserted as
FormulaLocal - no translation of string![]()
=IF(29,2;1)
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks