Delete a row

Anonymously

New Member
Joined
Mar 14, 2016
Messages
15
I have looked in multiple places for guidance on this, but nothing seems to make any sense. It seems to be a pretty simple line of code but it throws an error every time I run it.

Code:
Sheets("Process Shipment Out").Rows(2).EntireRow.delete

I've also tried:

Code:
Sheets{"Process Shipment Out").Range("A2").EntireRow.delete

The error I'm getting is "Delete method of Range class failed."

If anyone has a solution for this I would be grateful. I've been trying everything to make this work.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
No extra spaces. I've referenced the sheet in multiple other areas. I do still get that error without EntireRow.
 
Upvote 0
Assuming a sheet with the exact name "Process Shipment Out" (no extra spaces or ....), either of those lines should work. If the sheet exists and you have entered its tab name correctly, try retyping either line.
 
Upvote 0
Also, make sure that your sheet/range is not protected!

A good way to test is to try to delete it manually. Can you?

If so, turn on your Macro Recorder and record yourself deleting the row manually, then post that code here.
 
Last edited:
Upvote 0
Not that this should make a difference, but I'll post the entirety of the code here. Maybe I'm missing something. My array is working perfectly, it pastes the correct information, skips the information I don't care about, but simply won't delete this line when it's finished copying.

Code:
Sub ProcessShip()

Dim i As Integer, k As Integer, counter As Integer, v As Integer
counter = 0
v = 2
k = Sheets("Process Shipment Out").Range("A2").End(xlDown).Row - 1


For i = 0 To k


    If Sheets("Process Shipment Out").Range("N" & v) = "" Or Sheets("Process Shipment Out").Range("O" & v) = "" Or Sheets("Process Shipment Out").Range("P" & v) = "" Then
        counter = counter + 1
    Else
        Sheets("Process Shipment Out").Range("A" & v & ":P" & v).Copy
        
        With Sheets("Master List").Range("A" & Rows.Count).End(xlUp).Offset(1)
            .PasteSpecial Paste:=xlPasteValues
        End With
        
        With Sheets("Outstanding").Range("A" & Rows.Count).End(xlUp).Offset(1)
            .PasteSpecial Paste:=xlPasteValues
        End With
        
        Application.CutCopyMode = False
        Sheets("Process Shipment Out").Activate
        'On Error Resume Next
        Sheets("Process Shipment Out").Rows(v).delete


    End If
    v = v + 1
Next i


If counter = 0 Then
    Call MsgBox("There were no eligible shipments. Please fill out the shipping date, tracking number, and shipping cost for eligible shipments.", vbOKOnly, "No Shipments Found")
End If


End Sub
 
Upvote 0
Well I appreciate someone making me feel pretty stupid. I forgot that I'd turned on protecting this sheet from another macro. Unprotecting the sheet worked. Thanks for the quick feedback, everyone.
 
Upvote 0
This script works for me:
You may need to check the spelling of your sheet name
Code:
Sheets("Process Shipment Out").Rows(2).EntireRow.Delete



This script was wrong because you used a "{" and it should have been a "("
Code:
Sheets{"Process Shipment Out").Range("A2").EntireRow.delete
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
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