ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Object-defined error??? (https://www.excelbanter.com/excel-programming/316788-object-defined-error.html)

Michael Vaughan

Object-defined error???
 
Hello Everyone,

I ran into a strange problem. I developed a routine that checks dates and
entries associated to those dates and puts them into an array. Then
according to the dates, it writes to a "startup" page the entries that are
not logged in yet. It is notifying me to check a webpage for automatic
debits that should be posted. The program works great, BUT... I wrote it
separately to get all the bugs worked out, now that they are worked out, I
loaded it into my main program and now it doesn't work right. I keep
getting an "Application-defined or Object-defined Error" when it hits this
line: 'Sheets("Startup").Range("C9:G22").Select

'clear old entries
Sheets("Startup").Range("C9:G22").Select
Selection.ClearContents
Sheets("Startup").Range("E27").Select

Now, if I put a ' in front of those 3 lines of code above, then the program
works ok. Why will it not clear the contents of the Range C9:G22??? I
don't understand???

Beats my two pair??



Dave Peterson[_5_]

Object-defined error???
 
You can only select a range on the active worksheet.

So:
Sheets("startup").select
Sheets("Startup").Range("C9:G22").Select
Selection.ClearContents
Sheets("Startup").Range("E27").Select

or even just:
Sheets("Startup").Range("C9:G22").ClearContents

if you really don't need to select E27.


Michael Vaughan wrote:

Hello Everyone,

I ran into a strange problem. I developed a routine that checks dates and
entries associated to those dates and puts them into an array. Then
according to the dates, it writes to a "startup" page the entries that are
not logged in yet. It is notifying me to check a webpage for automatic
debits that should be posted. The program works great, BUT... I wrote it
separately to get all the bugs worked out, now that they are worked out, I
loaded it into my main program and now it doesn't work right. I keep
getting an "Application-defined or Object-defined Error" when it hits this
line: 'Sheets("Startup").Range("C9:G22").Select

'clear old entries
Sheets("Startup").Range("C9:G22").Select
Selection.ClearContents
Sheets("Startup").Range("E27").Select

Now, if I put a ' in front of those 3 lines of code above, then the program
works ok. Why will it not clear the contents of the Range C9:G22??? I
don't understand???

Beats my two pair??


--

Dave Peterson


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com