以下代码片段在英语版本的 Excel 中运行正常,但是当尝试在葡萄牙语版本的 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 的翻译函数没有机会将函数名称翻译为打开文档时通常会出现这种情况。
有任何想法吗?
Yes 格式条件公式必须使用本地格式.
我的解决方法是将所需的公式写入单元格,然后获取本地方程式该单元格的翻译应该是您语言的精确翻译:
Dim tmpCell As Range
Set tmpCell = Range("IV1")
tmpCell.Formula = "=mod(row(),2)=0"
.FormatConditions.Add(xlExpression, Formula1:=tmpCell.FormulaLocal)
不知道是否有更清洁的解决方案,但如果有的话我想知道,所以请分享......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)