Advance Filter - Multiple Conditions

  • It enables the user to execute to multiple filters
  •  

     

    Action: Place where result set should place

     

    XlFilterInPlace: to place in same location

    XlFilterCopy: to place in some other location

     

    Unique: True: to place Unique records, default is false

     

    Advance Filter - Example

     

  • Result displays in sheet3
  • Criteria mentioned in I1:J3
  •  

    Private Sub CommandButton1_Click()
    Range("A1").CurrentRegion.AdvancedFilter _
    Action:=xlFilterCopy, _
    criteriarange:=Range("I1:J3"), _
    copytorange:=Sheets("Sheet3").Range("A1"), _
    Unique:=False
    End Sub

     

     

     

    Advance Filter - Remove Duplicates

     

    Private Sub CommandButton1_Click()
    Dim r As Range
    Set r = Range("A1:A150")
    r.AdvancedFilter Action:=xlFilterCopy, copytorange:=Range("D1"), unique:=True
    End Sub