我正在尝试将VBA中的公式写入Excel工作表。这是我的代码:
destWorkBook.Sheets("Forecast Sheet").range("A" & i).Formula = "=IF(ISERROR(MATCH(C" & i & ", ""'Forecast Sheet Old'""!C:C,0)), ""'NEW'"", IF(H" & i & "=""'Forecast Sheet Old'""!H" & i & ",""''"",""'CHANGED'""))"
不管怎么说,无论我怎么做都不行:
destWorkBook.Sheets("Forecast Sheet").range("A" & i).Formula = "=IF(ISERROR(MATCH(C" & i & ", 'Forecast Sheet Old'!C:C,0)), 'NEW', IF(H" & i & "='Forecast Sheet Old'!H" & i & ",'','CHANGED'))"
就像这个或一百万个其他东西一样,它根本就没有采用这个公式。
错误消息是:
运行时错误1004:应用程序定义的错误或对象定义的错误
答案 0 :(得分:2)
这应该适用于许多撇号
destWorkBook.Sheets("Forecast Sheet").Range("A" & i).Formula = "=IF(ISERROR(MATCH(C" & i & ", 'Forecast Sheet Old'!C:C,0)), ""NEW"", IF(H" & i & "='Forecast Sheet Old'!H" & i & ","""",""CHANGED""))"