View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BOSS BOSS is offline
external usenet poster
 
Posts: 123
Default Advanced filter macro

I have a system fromwhich i need to prepare MIS.

I dump all the files into one file then i do advanced filter to get results
i need.

I recorded a macro and did come changes to make it suitable for my project.
below is the code.

' do advanced filter

Range("A1:AD65000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Sheets("Filterref").Range("A1:AD16"), Unique:=False
Sheets("raw").Select
Range("A1").Select

' copy required data into another sheet

ActiveCell.Range("A1:AD65000").Select
Selection.Copy
Sheets("brkp").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Sheets("raw").Select
Range("A1").Select

'remove filter
With ActiveSheet
If .FilterMode Then
.ShowAllData
End If
End With

Application.CutCopyMode = False

The filter is processed on the basis of the range specified.

"Sheets("Filterref").Range("A1:AD16"), Unique:=False"

Can the filter reference be something like

Range(Selection, Selection.End(xlUp)).Select

I mean can the range be set to all the cells in some specific sheet.

Please let me know. Thanks!
Boss