使用数组来拉取数据的多个variables并复制到另一个工作表

我有一个工作表,我想要在列“A”中search特定的条件,一旦我find多个variables,我正在寻找将所有在数组中的特定行复制到另一个工作表。 这里是我有的代码,我遇到了麻烦,只复制数组的最后一个数字的行(似乎我喜欢它是在彼此顶部复制,只保留在数组中的最后一个数字)。

Sub Copy_Changed_Rows() Dim Lastrow As Long With Sheets("DataDump") If .Range("A:A").Find("397", , xlValues, xlWhole, , , False) Is Nothing Then MsgBox "No ""Changed"" rows found. ", , "No Rows Copied": Exit Sub Else Application.ScreenUpdating = False Lastrow = .Range("A" & Rows.Count).End(xlUp).Row + 1 .Range("A1:A" & Lastrow).AutoFilter Field:=1, Criteria1:=Array("397", "437", "509", "646") .Range("A2:A" & Lastrow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Paste").Range("A2").PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, False .AutoFilterMode = False 'Position on cell A3 With Application .CutCopyMode = False .Goto Sheets("Paste").Range("A2") .ScreenUpdating = True End With MsgBox "All matching data has been copied.", , "Copy Complete" End If End With End Sub 

我发现filter行尾添加了一个缺失的filter, Operator:=xlFilterValues

 Sub Copy_Changed_Rows() Dim Lastrow As Long With Sheets("DataDump") If .Range("A:A").Find("397", , xlValues, xlWhole, , , False) Is Nothing Then MsgBox "No ""Changed"" rows found. ", , "No Rows Copied": Exit Sub Else Application.ScreenUpdating = False Lastrow = .Range("A" & Rows.Count).End(xlUp).Row + 1 .Range("A1:A" & Lastrow).AutoFilter Field:=1, Criteria1:=Array("397", "437", "509", "646"), Operator:=xlFilterValues .Range("A2:A" & Lastrow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Paste").Range("A2").PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, False .AutoFilterMode = False 'Position on cell A3 With Application .CutCopyMode = False .Goto Sheets("Paste").Range("A2") .ScreenUpdating = True End With MsgBox "All matching data has been copied.", , "Copy Complete" End If End With