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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,214,422
Messages
6,119,395
Members
448,891
Latest member
tpierce

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