|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
稍改一下就是了
- Private Sub CommandButton1_Click()
- Dim arr, brr, i&, n&, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- arr = Sheet1.[a2].CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = arr(i, 2)
- Next
- Set arr = Nothing '释放数组占用内存,提高速度
- n = [b65536].End(xlUp).Row - 1
- brr = [b2].Resize(n)
- For i = 1 To n
- brr(i, 1) = d(brr(i, 1)) '就地使用原数组,减少内存占用
- Next
- [a2].Resize(n) = brr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|