#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Error 1004

Hi all,

I am doing programming based on others' work. Many times, after I inserted
some code, I got runtime error 1004 and there are many reasons explaining it
such as can not use a method of a object (e.g. range). THese problem
statements are innocent before. Sometime, I change the inserted code position
or change some states like who is active sheet and errors gone. My question
what is the real reason and how can I prevent it or make capsule for my code?

Clara
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error 1004

Clara,

Post some problematic code problems.

Regards,
Eddie
http://www.ExcelHelp.us

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error 1004

A common problem is when you select ranges. You can only select ranges on the
activesheet.

Another common problem is when you don't fully qualify the range. If your code
is behind a worksheet, then any unqualified range belongs to the worksheet that
owns the code--not the activesheet.

So:

Worksheets("Sheet99").select
range("a1").select

May work in a general module--but will fail if the code is behind a worksheet
named Sheet1 (not sheet99).

worksheets("sheet99").select
worksheets("sheet99").range("a1").select
will work in both cases

with worksheets("sheet99")
.select
.range("a1").select
end with
will also work.

But there are very few things that need to be selected in your code.

Worksheets("Sheet99").range("a1").value = "hi there"
will work without the select's.

clara wrote:

Hi all,

I am doing programming based on others' work. Many times, after I inserted
some code, I got runtime error 1004 and there are many reasons explaining it
such as can not use a method of a object (e.g. range). THese problem
statements are innocent before. Sometime, I change the inserted code position
or change some states like who is active sheet and errors gone. My question
what is the real reason and how can I prevent it or make capsule for my code?

Clara
thank you so much for your help


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"