Hello experts,
I am trying to create a macro that inserts a formula into a cell, but I keep receiving a run-time error '1004' application-defined or object-defined error. I have tried several variations of the ActiveCell.Formula including .FormulaLocal.
Here is the portion of the code where the error is popping up:
Sub InsertFormulaIntoCell()
Range("P10").Select
ActiveCell.Formula = "=IFERROR((NETWORKDAYS.INTL(M8,O8,1,$Z$2:$Z$13)-(WORKDAY.INTL(M8-1,1,1,$Z$2:$Z$13)<M8)-(WORKDAY.INTL(O8-1,1,1,$Z$2:$Z$13)<O8))*($F$4-$F$3)+MAX(,MOD(O8,1)-$F$3)*(WORKDAY.INTL(O8-1,1,1,$Z$2:$Z$13)<O8)+MAX(,$F$4-MOD(M8,1))*(WORKDAY.INTL(M8-1,1,1,$Z$2:$Z$13)<M8),"")"
End Sub
Any advice or recommendations to enable the macro to correctly input this formula without error are greatly appreciated.
Best Regards,
Ray
Bookmarks