Run Time Error 1004

Matty2470

New Member
Joined
Mar 7, 2002
Messages
24
HI,

I have already taken advice for this problem but it still cuses errors.

I have the code

Sub Button157_Click()
Sheets("Sheet2").Rows("2").ClearContents
Sheets("Sheet4").Rows("2").ClearContents
End Sub

It works, but only at the second time of asking. The first time - I get the run time error message. I click 'end' try again and everything is fine.

What could be causing this?

THanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I seem to remember something about 1004 in Microsoft's Knowledge base when I was poking around for another problem. You might want to look there.
 
Upvote 0
I had a quick look, the error differs between xl97 and xl2000. And this error captures a lot of different types of errors in xl97, could you type the description you get with the error?

Nate
 
Upvote 0
Hi,

thanks for helping,

I get the message

'run time error 1004

clearContents method of range class failed'
 
Upvote 0
Matty,

there seems to be an issue with the a1 reference style, which we can explore in more detail if this doesn't work, but try the following code first:

Sub Button157_Click()
Worksheets("Sheet2").Rows("2").ClearContents
Worksheets("Sheet4").Rows("2").ClearContents
End Sub

I've seen Excel get finicky on the sheets vs. worksheets before.

If you're in XL97 and running the macro from a "Chart Sheet" you may want to select a different worksheet at the beginning of your code and return to it at the end. Last resort is to actually select the worksheets before clearing the respective contents. We'll turn the screenupdating to false, it shouldn't dampen performance time too much.

Hope this helps.

Cheers, Nate
This message was edited by NateO on 2002-03-12 08:51
 
Upvote 0
Hi

Set the TakeFocusOnClick Property of the CommandButton to False, or use one from the "Forms" toolbar

_________________
Kind Regards
Dave Hawley
OzGrid Business Applications
Microsoft Excel/VBA Training
0zGrid.BusApp.170x60.gif

This message was edited by Dave Hawley on 2002-03-12 08:50
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,163
Members
448,554
Latest member
Gleisner2

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