I'm trying to have a macro filter a range then delete the results if there are any. I have successfully created the code to filter the range, but I am unable to correctly delete the results. I'm trying to delete only the visible cells in that range, but the macro for some reason seems to be deleting the entire row even though i'm not telling it too. What's wrong??
Note: I posted this here a few days ago, with no luck: http://www.mrexcel.com/forum/showthread.php?t=454229
Private Sub DeleteZeroRows(ByVal wsheet As Worksheet)
Dim stripArrVar As Variant
Dim xArr As Variant
Dim firstRow As Long
Dim filterRng As Range
With wsheet
firstRow = .Range("HeaderRow").Row
stripArrVar = Array("AllA", "AllD", "AllH")
For Each xArr In stripArrVar
.AutoFilterMode = False
Set filterRng = .Range(.Cells(firstRow, .Range(xArr).Column - 4), .Cells(firstRow, .Range(xArr).Column + 2))
filterRng.AutoFilter Field:=5, Criteria1:=0
.Range(.Cells(firstRow + 1, .Range(xArr).Column - 4), .Cells(Rows.Count, .Range(xArr).Column + 2)).SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
Next xArr
.AutoFilterMode = False
End With
End Sub
Bookmarks