object not defined

tlindeman

Active Member
Joined
Jun 29, 2005
Messages
313
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
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
BTW, the worksheet that does not exist is the Schedule_jun spreadsheet, however, it will exist by the 20th of this month.

THank You
Tony
 
Upvote 0
You need to convert the text date. Try:

If Date >= cdate("07/22/2011")

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top