Error with IF/OR in VBA

前端 未结 2 380
时光取名叫无心
时光取名叫无心 2021-01-28 20:33
.Range(\"BS2:BS\" & NewLastRow).Formula = \"=IF((OR(BR2=\"\"FLAG\"\",BO2>0)),\"\"FLAG\"\",\"\"NOFLAG\"\" ))\"

I am using this formula in VBA but

相关标签:
2条回答
  • 2021-01-28 21:09

    In general, try the following:

    • Make a workable formula in Excel
    • Then select the cell with the workable formula
    • Run the following code

    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
    

    • In the immediate window something useful should be printed.

    Source: Apply formula in VBA?

    0 讨论(0)
  • 2021-01-28 21:14

    Too many ")"

    .Range("BS2:BS" & NewLastRow).Formula = "=IF(OR(BR2=""FLAG"",BO2>0),""FLAG"",""NOFLAG"" )"
    
    0 讨论(0)
提交回复
热议问题