【问题标题】:if statement inside formular1c1 and error 1004公式 1c1 中的 if 语句和错误 1004
【发布时间】:2015-03-28 14:05:30
【问题描述】:

我正在尝试使用我之前记录的 formulaR1C1 和 = IF() 自动填充一个范围,但我不断收到 1004 错误。 我有这个循环在这个特定的 sub 中运行了几次,它适用于所有其他公式,但是使用 = IF() 它不起作用......

rcell1.FormulaR1C1 = "=IF(RC[-1]>0;RC[-1];0)" 行被突出显示。

Set subgain = Range(Cells(i - period - 1, 16), Cells(i + j, 16))
With subgain
For Each rcell1 In subgain
       rcell1.FormulaR1C1 = "=IF(RC[-1]>0;RC[-1];0)"
Next rcell1
End With

有什么想法吗?

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    您的公式中有语法错误,您使用; 作为分隔符,但它应该改为,。替换这个:

    rcell1.FormulaR1C1 = "=IF(RC[-1]>0;RC[-1];0)
    

    用这个:

    rcell1.FormulaR1C1 = "=IF(RC[-1]>0,RC[-1],0)"
    

    它应该可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-13
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 1970-01-01
      相关资源
      最近更新 更多