'未作错误判断,假设都是5列,自己修改
Sub test()
Dim i As Long, j As Integer, n As Long
Sheet2.[a:e].ClearContents
With Sheet1
For i = 1 To .[a65536].End(xlUp).Row
If .Cells(i, 1) <> "J21" And .Cells(i, 2) <> "k880" And .Cells(i, 1) = "Y32" And .Cells(i, 3) = "CAV" Then
n = n + 1
For j = 1 To 5 '假设5列
Sheet2.Cells(n, j) = .Cells(i, j)
Next
End If
Next
End With
End Sub
直接用自动筛选(A列和B列),再复制到新工作表,可能更快也更实用一些。
其次用VBA。
在表头建立一个自动筛选, 在A列选自定条件等于J21 或 等于 Y32 , B列自定不等于K880 , C列等于CAV.