Run-time error: no cells found. Handling this error?

OfficeUser

Well-known Member
Joined
Feb 4, 2010
Messages
544
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I get a runtime error using this macro:
Code:
Private Sub DeleteRows()
On Error Resume Next
Columns("C:C").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub

It produces an error if there are no rows to delete. How do I prevent the error from happening? This macro is triggered from within a separate macro like this:
Code:
Run "DeleteRows"

Thanks for the help!!
 
With this in mind, I must admit I dont understand why you still get an error, especially bearing in mind that the msgbox showed 0.

Not sure either. I can post the entire code if it still helps you. I don't want to use up anymore of your time though since I have found a solution that works, unless you still think its worth looking at. Again, I appreciate the help.
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
If the msgbox said 0 when running the Delete Rows from another macro, then there is no need to post the other code, as that is not causing the problem.
 
Upvote 0
You're welcome. :)
Sorry I couldn't be of more help :(
 
Upvote 0

Forum statistics

Threads
1,223,983
Messages
6,175,778
Members
452,668
Latest member
mrider123

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