G
Gautam
Hi,
I am trying to delete rows in specific columns that have certain words
in them. I am a total newbie.
The error is: "Runtime Error 1004: AutoFilter method of Range Class
Failed"
When I debug the line that it doesn't like is:
" .Range("A1").AutoFilter Field:=8, Criteria1:="CAD" "
Here's my macro..
Sub DeleteBlankRows()
'Assumes the list has a heading.
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=8, Criteria1:="CAD"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=9, Criteria1:="TH"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=11,
Criteria1:="Financial"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=14,
Criteria1:="SENR"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Can you please help?
I am trying to delete rows in specific columns that have certain words
in them. I am a total newbie.
The error is: "Runtime Error 1004: AutoFilter method of Range Class
Failed"
When I debug the line that it doesn't like is:
" .Range("A1").AutoFilter Field:=8, Criteria1:="CAD" "
Here's my macro..
Sub DeleteBlankRows()
'Assumes the list has a heading.
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=8, Criteria1:="CAD"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=9, Criteria1:="TH"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=11,
Criteria1:="Financial"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=14,
Criteria1:="SENR"
.Range("A1").CurrentRegion.Offset(1,
0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
Can you please help?