Try this code
Option Explicit
Sub filter2050()
Dim wsData As Worksheet
Dim wsTarget As Worksheet
Dim rFilter As Range
Dim rCopy As Range
Dim i As Integer
Dim y As Integer
Dim Rw As Long
Set wsData = Sheet1
Set wsTarget = Sheet2
With wsData
Set rFilter = .Range(.Cells(1, 1), .Cells(.Rows.Count, 6).End(xlUp))
For i = 1 To 2
y = Choose(i, 20, 50)
With wsTarget
Rw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
End With
rFilter.AutoFilter Field:=4, Criteria1:=y
Set rCopy = rFilter
If Rw = 2 Then
rCopy.Copy wsTarget.Cells(1, 1)
Else: Set rCopy = .Range(.Cells(2, 1), .Cells(.Rows.Count, 6).End(xlUp))
rCopy.Copy wsTarget.Cells(Rw, 1)
End If
Next i
rFilter.AutoFilter
End With
End Sub
Bookmarks