Advanced Filter Demo : AdvancedFilter « Excel « VBA / Excel / Access / Word






Advanced Filter Demo

 
     Private Sub CommandButton1_Click()
         Dim rngData As Range
         Dim rngCriteria As Range
         Dim rngExtract As Range

         Set rngData = Workbooks("DataList5.xlsm").Worksheets("Sales").Range("Database")
         Set rngCriteria = ThisWorkbook.Worksheets("Sales").Range("Criteria")
         Set rngExtract = ThisWorkbook.Worksheets("Sales").Range("Extract")

         'Extract data with Advanced Filter
         rngData.AdvancedFilter Action:=xlFilterCopy, _
                              CriteriaRange:=rngCriteria, _
                              CopyToRange:=rngExtract, _
                              Unique:=False

     End Sub

 








Related examples in the same category

1.Do the Advanced Filter
2.AdvancedFilter Action:=xlFilterCopy