I am writing a excel macro with VBA that contains a simple formula:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=NOT(AND($L1>360;$K1<45))"
However, this does only work, if the language in excel is set to English. If the applicants language is for instance German, it looks like that:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=NICHT(UND($L1>360;$K1<45))"
Is there a way to use a generic one that works for all applicants?
Some requirements regarding the solution:
Any help is appreciated
Actually that is not possible, but there is a workaround.
First note that english versions use ,
instead of ;
as separator, so your english formula needs to be =NOT(AND($L1>360,$K1<45))
.
The workaround is to write that formula to any unused cell.
Range("unused_cell").Formula = "=NOT(AND($L1>360,$K1<45))"
Then read the localization of that
Dim FormulaLocal As String
FormulaLocal = Range("unused_cell").FormulaLocal
and use that as condition
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=FormulaLocal
That will translate the condition to the correct localisation of your Excel.