|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Macro1()
- Dim arr, brr, crr, d As Object, i&, j&, k&, s&, y&
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("a1").CurrentRegion
- crr = arr
- brr = Sheet2.Range("a1").CurrentRegion
- y = UBound(brr)
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = d(arr(i, 1)) & "," & i
- Next
- For i = 1 To UBound(brr)
- x = Split(Mid(d(brr(i, 2)), 2), ",")
- s = 0
- For j = 0 To UBound(x)
- s = j * y + i + 1
- For k = 1 To UBound(arr, 2)
- crr(s, k) = arr(x(j), k)
- Next
- Next
- Next
- Range("f1").Resize(UBound(crr), UBound(crr, 2)) = crr
- End Sub
复制代码 |
|