This is better
Sub Delete_with_Autofilter_Array()
Dim Rng As Range
Dim I As Long
Dim myArr As Variant
myArr = Array("ron", "Dave")
For I = LBound(myArr) To UBound(myArr)
ActiveSheet.Range("A1:A100").AutoFilter Field:=1, Criteria1:=myArr(I)
With ActiveSheet.AutoFilter.Range
Set rng = Nothing
On Error Resume Next
Set Rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not Rng Is Nothing Then Rng.EntireRow.Delete
End With
Next I
ActiveSheet.AutoFilterMode = False
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"Ron de Bruin" wrote in message ...
Hi Less
If you use And then use it like this
Example from my site :
Replace ron and dave to your criteria
Sub Delete_with_Autofilter_Array()
Dim Rng As Range
Dim I As Long
Dim myArr As Variant myArr = Array("ron", "Dave")
For I = LBound(myArr) To UBound(myArr) ActiveSheet.Range("A1:A100").AutoFilter Field:=1, Criteria1:=myArr(I)
With ActiveSheet.AutoFilter.Range
Set rng = Nothing
On Error Resume Next
Set Rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not Rng Is Nothing Then Rng.EntireRow.Delete
End With
Next I
ActiveSheet.AutoFilterMode = False
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"Les Stout" wrote in message ...
Dankie Ron. Ron can you help out with some code to create an Autofilter
on a spreadsheet. I was using the code below but now it gives me an
error !!
Rows("1:1").Select
' Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="=*ZA-T-M-*",
Operator:=xlAnd
Selection.AutoFilter Field:=10, Criteria1:="=*za-t-m-**",
Operator:=xlAnd
With Worksheets("Tabelle1")
If
AutoFilter.Range.Columns(1).Cells.SpecialCells(xlC ellTypeVisible) _
.Count = 1 Then
Else
With .AutoFilter.Range
.Resize(.Rows.Count - 1).Offset(1, 0).EntireRow.Delete
End With
End If
End With
Selection.AutoFilter Field:=10
Les Stout
*** Sent via Developersdex http://www.developersdex.com ***