error 1004 delete method of range class failed

Edu Vargas

New Member
Joined
May 16, 2022
Messages
5
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello guys.
I have created a macro linked to a script in SAP, it exports in an automated way a report directly from SAP, and once it gets done this report is edited in Excel.
I got a simple error in an operation that shouldn't be stopping my macro:
Sheets("VL06O_OTIF").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp

What should I do? Excel 2016 :(
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Which line of code is highlighted when that error occurs (hit the Debug option and see which line of code is highlighted)?

Are you ceratin you have a sheet named "VL06O_OTIF"?
If the error is occurring on that line, it means that you do not.
Note that any extra spaces or other characters will cause a non-match.
 
Upvote 0
Which line of code is highlighted when that error occurs (hit the Debug option and see which line of code is highlighted)?

Are you ceratin you have a sheet named "VL06O_OTIF"?
If the error is occurring on that line, it means that you do not.
Note that any extra spaces or other characters will cause a non-match.
Hello Joe.
The error occurs in the last líne:
Selection.Delete Shift:=xlUp

Yes there is a sheet with that name.
 
Upvote 0
Do you have merged or protected cells in row 1?

By the way, you original code can be simplified to:
VBA Code:
Sheets("VL06O_OTIF").Select
Rows("1:1").Delete Shift:=xlUp
There is usually no need to select ranges in order to work with them.
 
Upvote 0
Do you have merged or protected cells in row 1?
No Joe, this is a new sheet with info from SAP. No merged nor protected cells. Indeed I am trying to delete that row manually and it doesn't get deleted :(
 
Upvote 0
There must be something in row one preventing it from being deleted.
If the row is not hidden, protected, or contain merge cells, it should work.

What happens if you manually try to delete row one on that sheet?
Are you able to do that?
 
Upvote 0
There must be something in row one preventing it from being deleted.
If the row is not hidden, protected, or contain merge cells, it should work.

What happens if you manually try to delete row one on that sheet?
Are you able to do that?
No hidden, protected or merged cells Joe.
Nothing happens if I do it manually, just the contents get cleared, but the line is not deleted, I mean the line 2 doesn't go up.
 
Upvote 0

Forum statistics

Threads
1,225,841
Messages
6,187,331
Members
453,416
Latest member
JSmith0827

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