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
|