Trouble Deleting Sheet Rows in Table with Macro

ThiccNugg

New Member
Joined
Oct 24, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
For some reason this code keeps bring up the error "Delete method of Range class failed". However when doing it manually throughout excel via delete sheet rows it works fine. The code copied a whole dataset from a sheet and then I need to remove the rows with a blank cell in column X - this is where the issue occurs.

Sub BunnyHopperRoadsCopy()

Sheets("BCA").Select
Range("A2", Range("A" & Rows.Count).End(xlUp)).EntireRow.Select
Selection.Copy _
Destination:=Worksheets("BH ROADS").Range("A2")

Sheets("BH ROADS").Activate
Columns("X:X").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete shift:=xlUp

End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
You could try;
VBA Code:
Sheets("BH ROADS").Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
 
Upvote 0
VBA Code:
Sub BunnyHopperRoadsCopy()
Sheets("BCA").Range("A2", Range("A" & Rows.Count).End(xlUp)).EntireRow.Copy Destination:=Worksheets("BH ROADS").Range("A2")
Sheets("BH ROADS").Columns("X:X").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
End Sub
 
Upvote 0
VBA Code:
Sub BunnyHopperRoadsCopy()
Sheets("BCA").Range("A2", Range("A" & Rows.Count).End(xlUp)).EntireRow.Copy Destination:=Worksheets("BH ROADS").Range("A2")
Sheets("BH ROADS").Columns("X:X").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlUp
End Sub
Thanks for the reply but yeah still throwing that error with that code to..
 
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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