使用“= IF”时运行时错误“1004”

使用VBA将下面的公式添加到单元格失败,我无法解决原因:

"=IF($02,(IF(NOT($N2),$P1+1,1)),0)" 

我可以改变行,例如“= A2 / B2”,它运行良好。

完整代码:

 Sub FillDown() Dim strFormulas(1 To 2) As Variant With ThisWorkbook.Sheets("Sheet1") LRow = .Range("A99999").End(xlUp).Row strFormulas(1) = "=IF($02,(IF(NOT($N2),$P1+1,1)),0)" strFormulas(2) = "=A2/B2" .Range("L2:T2").Formula = strFormulas .Range("L2:T" & LRow).FillDown End With End Sub 

用这个:

  strFormulas(1) = "=IF($O2,(IF(NOT($N2),$P1+1,1)),0)" 

而不是这个:

  strFormulas(1) = "=IF($02,(IF(NOT($N2),$P1+1,1)),0)"