error message on delete empty rows macro

b.hill2387

New Member
Joined
Mar 28, 2012
Messages
38
I am trying to delete empty rows in the data sets that I import into excel. Sometimes the data sets have empty rows and sometimes they do not. The code below works in deleting empty rows if there are any, but if there are no empty rows to delete it comes up with a Run-time error 1004 saying "No cells were found" and highlights my second line of code. Is there a way to fix this? Thanks in advance.

Code:
Sheets("Comparison 1").Select 
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete 
Sheets("Comparison 2").Select 
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Im not good with VBA but would take the easy way out and put the following above your code.
Code:
On Error Resume Next

Sure someone on here will be able to help a bit more than that though
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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