I am having trouble adding a formula into a cell using the following macro:
i keep getting application defined or object defined error.
Code:
Private Sub OptAll_Click()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
Set FRPage = ThisWorkbook.Worksheets("fy10 v fy11 Revenue TREF Melb")
LastRow = Range("A" & Rows.Count).End(xlUp).Row
With FRPage
.Range("e5").Formula = "=+IFERROR(VLOOKUP($A5,'FY11 QME'!$A$7:$G$346,6,0),"")"
.Range("f5").Formula = "=IF(COUNTIF('FY11 QME'!$A$7:$A$346,$A5),IF(VLOOKUP($A5,'FY11 QME'!$A$7:$G$346,7,0)" _
& "="","",VLOOKUP($A5,'FY11 QME'!$A$7:$G$346,7,0)),"")"
.Range("g5").Formula = "=+IFERROR(e5/f5)"
.Range("q5").Formula = "=+IFERROR(VLOOKUP($A5,'FY12QME'!$A$7:$G$346,6,0),"")"
.Range("r5").Formula = "=IF(COUNTIF('FY12QME'!$A$7:$A$346,$A5),IF(VLOOKUP($A5,'FY12QME'!$A$7:$G$346,7,0)" _
& "="","",VLOOKUP($A5,'FY12QME'!$A$7:$G$346,7,0)),"")"
.Range("s5").Formula = "=+IFERROR(q5/r5)"
.Calculate
End With
With Application
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
i keep getting application defined or object defined error.