Within MS Access, I have the following snippet of code: -

Dim objExcelApp As Object
Set objExcelApp = CreateObject("Excel.Application")
With objExcelApp
strFile = "C:\Theatres Database\[Working Template v2 0.xls]LU"
.ActiveCell.FormulaR1C1 = "=IF(RC[-31]="""",""exclude"",IF(RC[-31]='" & strFile & "'!R1C2,""24hr"",IF(AND(RC[-31]<='" & strFile & "'!R2C2,RC[-29]>='" & strFile & "'!R3C2),""3 session day"",IF(AND(RC[-31]<='" & strFile & "'!R2C2,RC[-29]>='" & strFile & "'!R4C2),""2 session day"",IF(AND(RC[-31]<='" & strFile & "'!R2C2,RC[-29]>='" & strFile & "'!R5C2),""AM"",IF(AND(RC[-31]<='" & strFile & "'!R6C2,RC[-29]>='" & strFile & "'!R7C2),""PM"",IF(AND(RC[-31]<='" & strFile & "'!R8C2,RC[-29]>='" & strFile & "'!R9C2),""Evening"",IF(E2>='" & strFile & "'!$B$6,""2 session day"",""Aziz""))))))))"
End With
It's when I introduce the last bit i.e. IF(E2>='" & strFile & "'!$B$6,""2 session day"",""Aziz""))))))))" that I get the problem. I get a run time error 1004 i.e. 'Application defined or object defined error'.