.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中制作可行的公式
- 然后选择具有可行公式的单元格
- 运行以下代码
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中应用公式?