IF / OR在VBA中出错
.Range("BS2:BS" & NewLastRow).Formula = "=IF((OR(BR2=""FLAG"",BO2>0)),""FLAG"",""NOFLAG"" ))"
我在VBA中使用这个公式,但它不工作。 语法看起来不错。
太多 ”)”
.Range("BS2:BS" & NewLastRow).Formula = "=IF(OR(BR2=""FLAG"",BO2>0),""FLAG"",""NOFLAG"" )"
一般来说,请尝试以下操作:
- 在Excel中制作一个可行的公式
- 然后select具有可用公式的单元格
- 运行下面的代码
Public Sub PrintMeUsefulFormula() Dim strFormula As String Dim strParenth As String strParenth = """" strFormula = Selection.Formula strFormula = Replace(strFormula, """", """""") strFormula = strParenth & strFormula & strParenth Debug.Print strFormula End Sub
- 在即时窗口中应该打印一些有用的东西。
来源: 在VBA中应用公式?