|
参与一下。。。- Sub ykcbf() '//2024.2.28
- Set List = CreateObject("System.Collections.ArrayList")
- Set sh = ThisWorkbook.Sheets("筛选出A和B中多个相同的编码筛选出来")
- fns = [{"A", "B"}]
- On Error Resume Next
- With sh
- b = Split(.Cells(2, 2), "、")
- For i = 0 To UBound(b)
- s = b(i)
- If Not List.Contains(s) Then List.Add s
- Next
- b = Split(.Cells(2, 4), "、")
- For i = 0 To UBound(b)
- s = b(i)
- If Not List.Contains(s) Then List.Add s
- Next
- End With
- List.Sort
- ReDim brr(1 To 10000, 1 To 6)
- For x = 1 To 2
- With Sheets(fns(x))
- arr = .UsedRange
- For i = 3 To UBound(arr)
- s = CStr(arr(i, 1))
- For Each k In List
- If s = k Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- Next
- End With
- Next
- With sh
- .UsedRange.Offset(4) = ""
- .[a5].Resize(m, 6) = brr
- .[a5].Resize(m, 6).Sort .[a5], 1
- .[a5].Resize(m, 6).Borders.LineStyle = 1
- .[a4].Resize(1, 6).Interior.Color = 49407
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|