|
Private Sub CommandButton1_Click()
Dim br, r0&, c&, r&, ar, i&, j&, k&, n&, flg As Boolean
br = Sheet1.Range("A1").CurrentRegion.Resize(, 2)
r0 = UBound(br)
With Sheet2
c = .Cells(1, .Columns.Count).End(xlToLeft).Column
r = .Cells(.Rows.Count, 3).End(xlUp).Row
ar = .Range("a1").Resize(r, c): n = 1
For i = 2 To r
flg = True '先假设这一行需要保留
For k = 1 To r0
If InStr(ar(i, 3), br(k, 1)) > 0 Then flg = False: Exit For '在C列中找到,则不保留
Next
If flg Then '如果最终确认该行需要保留
n = n + 1
For j = 1 To c
ar(n, j) = ar(i, j) '转录数据
Next
End If
Next
.Range("A1").Resize(r, c).ClearContents '清除原数据
.Range("A1").Resize(n, c) = ar '写入整理后的数据
End With
End Sub
|
评分
-
1
查看全部评分
-
|