vba excel sheet1中保留sheet2中的选择项,其他的行删掉?
发布网友
发布时间:2022-12-22 15:24
我来回答
共1个回答
热心网友
时间:2024-11-17 20:42
Sub test1()
Dim i&, r&, rgs2 As Range
r = Sheets("Sheet1").Cells(Rows.Count, 2).End(3).Row
Set rgs2 = Range(Sheets("Sheet2").[a2], Sheets("Sheet2").Cells(Rows.Count, 1).End(3))
For i = r To 2 Step -1
With Sheets("Sheet1").Cells(i, 2)
If rgs2.Find(.Text, , , 1) Is Nothing Then
.EntireRow.Delete
End If
End With
Next
End Sub