|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST7()
Dim ar, br, cr, vResult, i&, j&, k&, r&, dic As Object, vKey, t#
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
t = Timer
ar = Range("B1", Cells(Rows.Count, "P").End(xlUp)).Value
br = Array(2, 1, 3, 13, 15)
ReDim vResult(1 To UBound(ar), 1 To 5)
For j = 0 To UBound(br)
vResult(1, j + 1) = ar(1, br(j))
Next j
r = r + 1
For i = 2 To UBound(ar)
vKey = Right(ar(i, 2), 2)
dic(vKey) = dic(vKey) & " " & i
Next i
For Each vKey In dic.keys
cr = Split(dic(vKey))
If UBound(cr) > 1 Then
For j = 1 To UBound(cr)
r = r + 1
For k = 0 To UBound(br)
vResult(r, k + 1) = ar(cr(j), br(k))
Next k
Next j
End If
Next
Range("Y9:AC" & Rows.Count).Clear
[Y9].Resize(r, 5) = vResult
Set dic = Nothing
Application.ScreenUpdating = True
MsgBox "执行完毕!_用时: " & Format(Timer - t, "0.00") & " 秒", 64
End Sub
|
评分
-
3
查看全部评分
-
|