|
字典+数组经典用法- Sub ykcbf() '//2024.3.14
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("表一")
- r = .Cells(.Rows.Count, 4).End(xlUp).Row
- arr = .[a1].Resize(r, 4)
- End With
- For i = 5 To UBound(arr)
- s = arr(i, 4)
- d(s) = d(s) + 1
- Next
- With Sheets("表二")
- r = .Cells(.Rows.Count, 4).End(xlUp).Row
- arr = .[a1].Resize(r, 5)
- For i = 6 To UBound(arr)
- s = arr(i, 4)
- If d.Exists(s) Then
- arr(i, 5) = d(s)
- End If
- Next
- .[a1].Resize(r, 5) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|