|
本帖最后由 ykcbf1100 于 2024-3-18 15:20 编辑
用2个字典是因为O列有重复,要去重。- Sub ykcbf() '//2024.3.18
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set Sh = ThisWorkbook.Sheets("结果")
- With Sh
- arr = .UsedRange
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- d(s) = i
- Next
- End With
- On Error Resume Next
- With Sheets("基础数据")
- r = .Cells(Rows.Count, "o").End(3).Row
- arr = .Range("o1:o" & r)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If d(s) = Empty Then d1(s) = ""
- Next
- End With
- With Sh
- r = .Cells(Rows.Count, 1).End(3).Row
- .Cells(r + 1, 1).Resize(d1.Count, 1) = WorksheetFunction.Transpose(d1.keys)
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|