Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error 1004
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |