
07-06-2005, 07:11 AM
|
|
Freshman
|
|
Join Date: Dec 2003
Posts: 25
|
|
Autofilter with multiple columns and multiple criteria
|
Hi
I have a sheet of data, which I need to clear up. What I want to do is use the autofilter function to filter out the information that I need, leaving what I don't need visible and then delete the visible rows.
First filter is on column D, where I need to select all rows that are in "Unit1" and then filter on column C to select all rows that are NOT "Team1" or "Team2".
Code I have is:
vb/
Dim CheckRange As Range, DeleteRange As Range
Set CheckRange = Worksheets("Sheet1").Columns(7)
CheckRange.AutoFilter Field:=4, Criteria1:="Unit1"
CheckRange.AutoFilter Field:=3, Criteria1:="<>Team1", Operator:=xlOr, Criteria2:="<>Team2"
Set DeleteRange = CheckRange.SpecialCells(xlCellTypeVisible).EntireRow
DeleteRange.Delete
/vb
However this does not work. It filters out all the non "Unit1" rows fine, but then applied a filter to Column C that does nothing!
Can someone help put me out of my misery?
|
|