Run-time error 1004 - No cells were found

excelnewbie1986

New Member
Joined
May 16, 2018
Messages
16
Hi all,

Hoping someone can help! When running the macro below, I am getting a run-time error 1004 - No cells were found error. I have tried diagnosing this issue myself, but am at a loss. This macro worked perfectly on the worksheet it was originally created on. So I used that worksheet as a template, and I then paste a tonne of raw data into the template to run the macro to remove certain things, but now when I run the macro in subsequent copied versions of the template, it no longer works. The blue text denotes where the debugger has picked up the error.

Application.ScreenUpdating = False
With Range("Z:Z")
.Replace "G", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

Application.ScreenUpdating = False
With Range("V:V")
.Replace "WATERS EDGE PRIMARY SCHOOL", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

Application.ScreenUpdating = False
With Range("V:V")
.Replace "Green Abbeys", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

With Range("W:W")
.Replace "331", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

With Range("W:W")
.Replace "860", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

With Range("W:W")
.Replace "", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

With Range("Y:Y")
.Replace "", "=GGG", xlWhole, , False, , False, False
.SpecialCells(xlFormulas, xlErrors).EntireRow.Delete
End With

Thanks in advance!!
 
Firstly, when posting code, please use code tags, the # icon in the reply window.
Secondly this
Prior to running the macro, there are values of 'G' in column Z. When I run the macro and it produces the runtime error, when I click OK, the values of 'G' have disappeared from column Z,
combined with
And there are no cells that say #NAME either.
Makes no sense to me.
If the code found a value of G in col Z it would be replaced with #NAME? & the Specialcells line of code would then delete those rows. No Error message.
If the code did not find G then you would get the error message, but no rows would have been deleted.

Do you have any event code running on that sheet?
 
Last edited:
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Firstly, when posting code, please use code tags, the # icon in the reply window.
Secondly this combined with Makes no sense to me.
If the code found a value of G in col Z it would be replaced with #NAME ? & the Specialcells line of code would then delete those rows. No Error message.
If the code did not find G then you would get the error message, but no rows would have been deleted.

Do you have any event code running on that sheet?

Unfortunately, I don't know what event code is, sorry :(. I'm pretty sure you gave me that removal sub originally - and it worked perfectly. It just doesn't seem to want to work now. The raw data I put into the master spreadsheet always (to start with) has values of G in col Z. After I run the macro and get the runtime error, when I close it, all the values of G are removed (along with the row), but nothing else after that point.
 
Upvote 0
Are you sure that it's failing on Col Z, rather then on one of the later columns?
 
Upvote 0
Are you sure that it's failing on Col Z, rather then on one of the later columns?

It is failing on one of the later columns! My colleague had changed the SQL stored procedure to not collect Water's Edge and Green Abbey (which are test databases anyway).....he just failed to tell me. Removing those to sections of code and it now works perfectly again!

Thanks once again @Fluff :)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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