Run-time error '1004'

  • Thread starter Thread starter steelrat
  • Start date Start date
Application-defined or object-defined error. This is a very commo
"catch-all" error message. This error occurs when an error does no
correspond to an error defined by VBA. In other words, the error i
defined by Excel (or some other object) and is propagated back t
VBA. This error also occurs if you generate an error (using the Rais
method of the Err object) and the error is not defined by VBA.

[John Walkenbach, -Excel 2002 Power Programming-, p. 880.]

Thus, any error that can not be placed under a specific category o
errors
 
Thanks for the info. Any idea on how to get rid of or
fix it?
-----Original Message-----
Application-defined or object-defined error. This is a very common
"catch-all" error message. This error occurs when an error does not
correspond to an error defined by VBA. In other words, the error is
defined by Excel (or some other object) and is propagated back to
VBA. This error also occurs if you generate an error (using the Raise
method of the Err object) and the error is not defined by VBA.

[John Walkenbach, -Excel 2002 Power Programming-, p.
880.]

Thus, any error that can not be placed under a specific category of
errors.
 
Because it is such a generic error message, it might be difficult t
pinpoint.

What code were you using when it occurred
 
Excel opens files in your XLStart folder and addins checked in Tools|Addins.

It could be any of the workbooks in either spot.

You can move stuff out of XLStart and uncheck everything in Tools|addins. (Keep
notes!)

Then start adding things back one at a time until you find the problem
workbook. Then you'll have to decide what to do with it.

(and put everything else back the way it was).

Chip Pearson has some additional notes to help diagnose this kind of problem at:
http://www.cpearson.com/excel/StartupErrors.htm
 
I am getting the same error code. It happens when I am running a simple recorded macro that sorts data in Excel. This works on several computers but I am getting the error on one specific machine. Can anyone help me.
----- shades > wrote: -----

Because it is such a generic error message, it might be difficult to
pinpoint.

What code were you using when it occurred?
 
You'll want to post the portion of code that gets the error (identify it in
context) and where the code is (in a general module or behind a worksheet).

My guess with no knowledge at all is that you've either got an unqualified range
and it's not refering to the same worksheet that you think it is:

with worksheets("Sheet1")
.range("a1:x99").sort key1:=range("a1"), ...
end with

That key1:=range("a1") is an unqualified range. If Sheet1 isn't active, then
it'll blow up.

with worksheets("Sheet1")
.range("a1:x99").sort key1:=.range("a1"), ...
end with

with that extra dot, it means that .range("a1") belongs to the object in the
previous With statement--sheet1 in my example.

====
Second guess:
That problem pc is still running xl97 and the others are running xl2k or higher.

And you're calling the macro by a control from the control toolbox toolbar
(commandbutton????) placed on the worksheet.

If both of these are true, then change the .takefocusonclick property to false
for that control. If it doesn't have that property, add:

activecell.activate

to the top of your code.

(this bug was fixed in xl2k.)
 
Back
Top