在VBA中插入公式时,VBA公式应用程序定义或对象定义的错误

我试图用公式replace结果,所以用户将能够看到值和公式。

Sub MoreOrEqualAmountCalculated() Dim LastRow As Long Dim Counter As Long With Application .ScreenUpdating = False End With Application.Workbooks("Summary.xlsm").Worksheets("MonthlyData_Raw").Activate LastRow = Range("A1000000").End(xlUp).Row For Counter = 2 To LastRow 'Populate both results and FORMULA: There is an error 1004 - application-defined or object-'defined error. What am I missing? Cells(Counter, 36).Formula = "=IF(Cells(Counter, 35).Value >= 0,""Recovery _ Equals or Exceeds Amount calculated"",""Recovery less than Amount _ calculated"")" Next With Application .ScreenUpdating = True End With End Sub 

我已经看到了一些相关的主题,但是如果他们详细解释了关于插入公式的规则,就没有一个。 感谢您的帮助和明确的解释,以便将来能够应用这些知识。

拉斯,非常感谢

尝试这个:

  Cells(Counter, 36).Formula = "=IF(" & Cells(Counter, 35).Address & " >= 0,""Recovery " & _ "Equals or Exceeds Amount calculated"",""Recovery less than Amount " & _ "calculated"")"