Run-time error 1004

xluserg

Board Regular
Joined
Jan 30, 2010
Messages
121
Office Version
  1. 365
Platform
  1. Windows
Hi all

office 365

I have an Excel problem with many files. Run-time error 1004 had this for a week now I can't solve the problem and hope to find an answer here.

Sub Macro1()
'
' Macro1 Macro
Sheets("Sheet1").Select
Application.Goto Reference:="R1C1"
ActiveCell.FormulaR1C1 = "1"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "2"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "3"
ActiveCell.Offset(1, 0).Range("A1").Select
Application.Goto Reference:="R1C1"
ActiveCell.Rows("1:3").EntireRow.Select
Selection.Delete Shift:=xlUp stops here.... Run-time error 1004 Delete method of range class failed

End Sub

The 1. 2. 3, are removed then I get the error.

any help appreciated

Graham
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I don't like the use of ActiveCell in the use of VBA code, especially at the beginning. You have no idea where you are to start, and thus moving around could request an illegal move (i.e. above row 1, to the left of column A, etc). I am pretty sure that code could be re-written much better, in a manner that will make it less error prone.

Can you describe, in plain English, exactly what you want this code to do?
 
Upvote 0
Hi Joe4

' Macro1 Macro
Sheets("Sheet1").Select
Application.Goto Reference:="R1C1" 'start cell


I was just wanting to find out why I get the error


Graham
 
Upvote 0
Any sheet protection or merged cells?
 
Upvote 0
I thought you said you were getting the error on this line:
VBA Code:
Selection.Delete Shift:=xlUp stops here.... Run-time error 1004 Delete method of range class failed

So which one is it?
 
Upvote 0
I thought you said you were getting the error on this line:
VBA Code:
Selection.Delete Shift:=xlUp stops here.... Run-time error 1004 Delete method of range class failed

So which one is it?
Yes after Selection.Delete Shift:=xlUp 'stops here.... Run-time error 1004 Delete method of range class failed

The numbers are gone so it seems to delete the 3 rows. but then I get the error. If I wanted to add more code after the error it would not run that code.

Thanks

Graham
 
Upvote 0
I think it might be better off to scrap what you have, and rewrite better code.
But in order to do that, we need to understand exactly what you are trying to do and how you want it to work.
I do not like to try to reverse engineer that and try to figure it out from your code, because if there is some flaw in the logic of the code, we would have a good understanding of what you are trying to do.
So can you please quite simply explain (in plain English) exactly what this current code should be doing?
 
Upvote 0
Yes after Selection.Delete Shift:=xlUp 'stops here.... Run-time error 1004 Delete method of range class failed

The numbers are gone so it seems to delete the 3 rows. but then I get the error. If I wanted to add more code after the error it would not run that code.
If it errors on that line the numbers should not disappear because the line errored out and didn't execute.

The only way I have been able to replicate the error on that line is to have an Excel Table to the right which starts on one of the rows 1:3 and then extends past row 3.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,844
Members
449,051
Latest member
excelquestion515

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