If Then Filter not working

thardin

Board Regular
Joined
Sep 29, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Hello.
I'm trying to filter a database that looks like this:
1635362146390.png


I'm trying to filter Column T so all rows are deleted besides the ones that start with MFS or #N/A(take a look at rows 18 and 19 in column T)
If there are no results, I want to clear filters, run a macro that enters "No violations" at the end of the dataset(look at code), and then save and close workbook. Or else do nothing.

Here is the code I have and I've tested and tried different alternatives and still getting multiple errors. I'm not sure if something is out of order or what.
What can I do to fix this?

Sub Filter()
' FilterMacro
' Keyboard Shortcut: Ctrl+p


With ActiveSheet
.Range("A1:T1").AutoFilter Field: = 20, "<>MFS*", xlAnd, "<>#N/A"
.AutoFilter.Range.Offset(1).EntireRow.Delete

If .AutoFilter.Range.Columns(1).SpecialCells(xlVisible).Count = 1 Then
.AutoFilterMode = False:
Application.Run "PERSONAL.XLSB!FirmSignoff"

'ActiveWorkbook.Close SaveChanges:=True --> closes and signs even if there are results

End If
End With


End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

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