View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_907_] joel[_907_] is offline
external usenet poster
 
Posts: 1
Default Filtering by three criteria including top ten value


There was no attachment. the code below uses autofilter to filter the
3 columns. then the code uses specialcells to select the visible rows
to get the results. I basically recorded a macro and then editied the
macro to simplify the code.



Sub Gettop10()

ColACriteria = "a"
ColBCriteria = "B"
LastRow = Range("A" & Rows.Count).End(xlUp).Row

Columns("A:C").AutoFilter
Columns("A:C").AutoFilter Field:=1, Criteria1:="a"
Columns("A:C").AutoFilter Field:=2, Criteria1:="b"
Columns("A:C").AutoFilter Field:=3, _
Criteria1:="10", Operator:=xlTop10Items

Set top10 = Rows("1:" & LastRow).SpecialCells(Type:=xlCellTypeVisible)

top10.Select

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=196213

http://www.thecodecage.com/forumz