In my vba code I am pointing to a spreadsheet that does not exist yet. I thought I took care of that by putting an if statement, however I am getting an "obeject not defined" Could someone please provide a workaround? Here is a snippet of my code:
If Date >= "07/22/2011" Then
Range("N2").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$7"
Range("N3").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$8"
Range("N4").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$9"
Range("N8").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$13"
Range("N9").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$14"
Range("N10").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$15"
Range("N11").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$16"
Range("N12").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$17"
Else
Range("N2").Formula = "=L2"
Range("N3").Formula = "=HLOOKUP(N16,'Cash Flow Projection 2011'!V7:JM200,36,FALSE)/1000"
Range("N4").Formula = "=L4"
Range("N8").Formula = "=SUM('[2011 Balance Sheet by Month.xlsx]BS'!$BV$55+'[2011 Balance Sheet by Month.xlsx]BS'!$BV$61)"
Range("N9").Formula = "=L9"
Range("N10").Formula = "=L10"
Range("N11").Formula = "=L11"
Range("N12").Formula = "=L12"
End If
End Sub
If Date >= "07/22/2011" Then
Range("N2").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$7"
Range("N3").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$8"
Range("N4").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$9"
Range("N8").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$13"
Range("N9").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$14"
Range("N10").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$15"
Range("N11").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$16"
Range("N12").Formula = "='R:\ACCT\FINREPORTING\FS2011\Ratios\CAPX Ratios\[Indebtedness.xlsx]Schedule_Jun!$E$17"
Else
Range("N2").Formula = "=L2"
Range("N3").Formula = "=HLOOKUP(N16,'Cash Flow Projection 2011'!V7:JM200,36,FALSE)/1000"
Range("N4").Formula = "=L4"
Range("N8").Formula = "=SUM('[2011 Balance Sheet by Month.xlsx]BS'!$BV$55+'[2011 Balance Sheet by Month.xlsx]BS'!$BV$61)"
Range("N9").Formula = "=L9"
Range("N10").Formula = "=L10"
Range("N11").Formula = "=L11"
Range("N12").Formula = "=L12"
End If
End Sub