Language independent VBA Programming

Soly

New Member
Joined
Dec 13, 2010
Messages
2
Hello,

I am creating an excel tool that is used by people all working with the same Excel version (2007), but various language settings (English (UK), German, French, Spanish...)
I created the code using English (U.S.) settings. Formulas in the worksheets are translated automatically, however problems arise with formulas created by a vba script.

Here is a piece of code to illustrate the problem:

Code:
Mycond1= "=AND(A1>=A2; A2>=A3)"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=Mycond1

The condition is written to the selected cell in English, no matter how the local language settings are.

Is there any possibilty to tell vba to translate this to the local language? I read about "FormatLocal", but it does not seem to be applicablen here.

I would appreciate any ideas! Thanks a lot in advance!

Best regards,
Soly
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I'm curious to find out if there is some sort of elegant solution to this as well.

If you meant by "creating an excel tool", you are creating an Add-In, here's sort of a kludge.

You're add-in will have its own worksheet the user wouldn't see. You could store a dummy formula on that sheet. Excel will automatically convert that dummy formula to the local language setting. Have your code read that formula and then use it elsewhere in the code.
 
Upvote 0
Hello,

I found a workaround for my problem. I write my formula to a field and read it in again, now with local settings. This works. However, there shouldt be a more elegant solution (so I do not mark this threat as solved yet)...

Code:
Mycond1="=AND(A1>=A2, A2>=A3"
Range("tempfield").FormulaR1C1 = Mycond1
Mycond1 = Range("tempfield").FormulaLocal
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= Mycond1

Regards,
Soly
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,358
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top