|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST5()
Dim ar, br, i&, j&, r&, k&, dic As Object, iPosRow&
Set dic = CreateObject("Scripting.Dictionary")
ar = Sheets(1).UsedRange
ReDim br(1 To 10 ^ 3, 1 To 3)
For j = 1 To UBound(ar, 2) Step 4
For i = 2 To UBound(ar)
If Len(ar(i, j)) Then
If Not dic.exists(ar(i, j)) Then
r = r + 1
dic(ar(i, j)) = r
For k = 1 To 3
br(r, k) = ar(i, j - 1 + k)
Next k
Else
iPosRow = dic(ar(i, j))
br(iPosRow, 2) = br(iPosRow, 2) & "、" & ar(i, j + 1)
br(iPosRow, 3) = br(iPosRow, 3) + ar(i, j + 2)
End If
End If
Next i
Next j
[F1].CurrentRegion.Clear
[F1].Resize(, 3) = Array("姓名", "职务", "得分")
[F2].Resize(r, 3) = br
Set dic = Nothing
Beep
End Sub
|
|