#REF! error with VBA auto-filter formula to delete rows that contain text

shagan101

New Member
Joined
Apr 26, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I'm struggling with a #REF! error showing up in certain cells after running a script to remove cells containing the specific text below. Column B is a =text(A#,"ddd") formula but column A has no references to any other cells.... Have to run the same routine every day and would really like a macro that doesn't break the data. Any suggestions? See images below of snippets of sheets.

VBA Code:
Sub deleteOlympicsrows()
    Rows("1:1").Select
    Selection.AutoFilter
    Range("D1").Select
    ActiveSheet.Range("$A$1:$C$10000").AutoFilter Field:=3, Criteria1:= _
        "=*OLYMPICS*"
    ActiveSheet.Range("$A$1:$C$10000").Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.delete
    ActiveSheet.AutoFilterMode = False
End  Sub


Before (left) and after (right)
before.png
after.png
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the MrExcel board!

When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊

Could we have that sample data (A1:C34), including formulas, with XL2BB so that we can test with your actual situation?
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,042
Members
449,063
Latest member
ak94

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