3
I am having trouble deleting lines resulting from a text filter in a table. I recorded a macro that resulted in the following code:
ActiveSheet.Range("$A$1:$K$161").AutoFilter Field:=2, Criteria1:= _
"=*EXT-11198*", Operator:=xlAnd
Rows("30:200").Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$K$139").AutoFilter Field:=2"
It only worked for that specific table, when I apply it to another table with different number of records or the macro deletes more or less records.
I believe that inserting a routine that counts the resulting lines of the filter and deletes only those lines solves the problem.
You are applying the filter up to line 161, so of course, if another sheet has a larger size, the filter will not affect it (as you said yourself). Also, you are deleting from 30 to 200. What is the parameter to delete this range of lines?
– César Rodriguez
Calculating the last line is easy, but the second part depends on why you want to specifically delete filtered lines 30 to 200.
– César Rodriguez
The selection up to the 200 line was random, what needs is to select all lines that contain a code, in this case "EXT-11198" and delete them before processing the rest of the macro.
– marcilio-dev