在外语版本的Excel中调用vba中的Worksheet函数

下面的代码snipet在Excel的英语版本中运行OK,但是当试图在葡萄牙语Excel版本的同一工作簿中运行此代码时,它会出错。

' Add color bars on every other row - attempt to make list ' easier to read. ' "PlaceAt" is a worksheet range passed into the function With Range(PlaceAt.offset(1, 0), PlaceAt.offset(i + 1, 7)) .FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)=1" .FormatConditions(1).Interior.ColorIndex = 20 End With 

我认为问题在于,葡萄牙语中的ROW函数拼写为LIN(不知道MOD函数是什么),并且由于函数是使用vba插入的,因此Excel的翻译函数没有机会将函数名称转换为它通常会打开文档。

有任何想法吗?

FormatConditions公式必须使用本地格式

我的解决方法是将想要的公式写入单元格中,然后获取该单元格的FormulaLocal ,这应该是您的语言的确切翻译:

 Dim tmpCell As Range Set tmpCell = Range("IV1") tmpCell.Formula = "=mod(row(),2)=0" .FormatConditions.Add(xlExpression, Formula1:=tmpCell.FormulaLocal) 

不知道是否有一个更清洁的解决scheme,但如果是这样我想知道,所以请分享…