Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting rows containing the Auto Filter

Status
Not open for further replies.

Mizzness

Programmer
May 2, 2003
174
US
Hello All.

I want to delete all rows that contain 8 digits/numerics (i.e.: 45876523) in column "A".

Here is my code with my criteria denoted by the ??? marks.

Thanks in advance.
Mizzness

With Sheets("PV").Columns("A:A").Rows("3:3000")
.AutoFilter Field:=1, Criteria1:="=*????*"
.EntireRow.Delete Shift:=xlUp
End With
 
Skip,

Thanks for the quick reply.
Let me clarify though, I want the macro to delete all rows with an eight digit number in column "A".
Can this be done in the same context as if I'm trying to delete rows that contain a certain keyword ?

Thanks.
Mizzness
 
Code:
    ActiveSheet.Cells(1, 1).AutoFilter
    With ActiveSheet.Columns("A:A").Rows("2:5")
        .AutoFilter Field:=4, Criteria1:="8"
        .EntireRow.Delete Shift:=xlUp
    End With
where COL 4 is the LEN of col A (I had 5 rows)

Skip,
Skip@TheOfficeExperts.com
 
Hi Mizzness,

You can filter on a range, so try ...

Code:
.AutoFilter Field:=1, Criteria1:=&quot;>=10000000&quot;, Operator:=xlAnd, Criteria2:=&quot;<=99999999&quot;

Enjoy,
Tony
 
Tony,

Sorry for getting back to you so late.
This is definitely along theline of what I am trying to do.
However, it's still not working.
I've pasted the code if you could give it a look.
In the meantime, the testing continues.

Regards,
Mizzness

With Sheets(&quot;PV&quot;).Columns(&quot;A:A&quot;).Rows(&quot;3:3000&quot;)
.AutoFilter Field:=1, Criteria1:=&quot;>=10000000&quot;,
Operator:=xlAnd, Criteria2:=<&quot;=999999999&quot;
.EntireRow.Delete Shift:=xlDown
End With
 
Tony,

Disregard prior message; problem solved.

Thanks.
Mizzness
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top