|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 chenbiao2012 于 2015-4-4 20:59 编辑
- Sub test()
- Set d = CreateObject("scripting.dictionary")
- With Sheets("A")
- arr = .[a1].CurrentRegion
- For i = 1 To UBound(arr)
- d(arr(i, 1) & arr(i, 3)) = Array(arr(i, 1), arr(i, 2), arr(i, 3))
- Next
- End With
- With Sheets("B")
- arr = .UsedRange
- For i = 1 To UBound(arr)
- For Each kk In d.keys
- If InStr(kk, arr(i, 1)) > 0 And InStr(kk, arr(i, 3)) > 0 Then
- For j = 1 To 3
- arr(i, j) = d(kk)(j - 1)
- Next
- End If
- Next
- Next
- .[a1].Resize(UBound(arr), 3) = arr
- End With
- End Sub
复制代码 |
|