Try this
Code:
Sub FilterData()
Dim rngFilterRange As Range
Dim rngToCopy As Range
With Sheet1
If .AutoFilterMode = True Then .AutoFilterMode = False
Set rngFilterRange = .Range("A1").CurrentRegion
'=============For xx==================================
'====Applied Filter for Words contains XX ===========
rngFilterRange.AutoFilter Field:=5, Criteria1:="=*xx*", Operator:=xlAnd
'=====Creating Range to Copy ========
Set rngToCopy = .Range("A1").CurrentRegion.Offset(1).SpecialCells(xlCellTypeVisible)
'=====Copying Range =================
rngToCopy.Copy
'=====Pasting Data in Sheet 2 ==================
Sheet2.Range("A" & .Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
'=============For yy==================================
If .AutoFilterMode = True Then .AutoFilterMode = False
'====Applied Filter for Words contains yy ===========
rngFilterRange.AutoFilter Field:=5, Criteria1:="=*yy*", Operator:=xlAnd
'=====Creating Range to Copy ========
Set rngToCopy = .Range("A1").CurrentRegion.Offset(1).SpecialCells(xlCellTypeVisible)
'=====Copying Range =================
rngToCopy.Copy
'=====Pasting Data in Sheet 3 ==================
Sheet3.Range("A" & .Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
If .AutoFilterMode = True Then .AutoFilterMode = False
End With
End Sub
Bookmarks