Excel Macro, inserting internationally valid formula during run-time

前端 未结 6 715
无人共我
无人共我 2020-12-01 15:59

I\'ve got an Excel spreadsheet, with a Macro, that inserts a conditional formatting, like this:

Selection.FormatConditions.Add Type:=xlExpression, Formula1:=         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 16:26

    Store (a trivial version of) the formula in a (hidden) cell in your workbook.

    Then when you open the workbook that formula will be translated automatically by excel for the user.

    Now you just have to dissect this formula in your script (find the opening bracket "(" and take the past left of that:

    Use something like:

    strLocalizedFormula = Mid(strYourFormula, 2, InStr(1, strYourFormula, "(") - 2)

    where strYourFormula will be a copy from the formula from your worksheet.

    I hope this works as I only use an English environment.

    Also from reading this: http://vantedbits.blogspot.nl/2010/10/excel-vba-tip-translate-formulas.html I am thinking you should (only) be able to use the english version of a cell formula from VBA.

提交回复
热议问题