|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 mjzxlmg 于 2011-10-1 16:37 编辑
Sub test()
Application.ScreenUpdating = False
Dim arr, brr(), i&, d As Object, m&
Set d = CreateObject("scripting.dictionary")
arr = Sheets(1).Range(Sheets(1).[a2], Sheets(1).[ab65536].End(3))
drr = Sheets(2).Range("a1:a" & Sheets(2).Range("a" & Rows.Count).End(3).Row)
ReDim brr(1 To UBound(arr), 1 To 6)
For i = 1 To UBound(arr)
If Not d.exists(arr(i, 9)) Then
m = m + 1
d(arr(i, 9)) = m
brr(m, 1) = arr(i, 9)
brr(m, 2) = arr(i, 12): brr(m, 3) = arr(i, 14): brr(m, 4) = arr(i, 15): brr(m, 5) = arr(i, 3): brr(m, 6) = arr(i, 4)
Else
brr(d(arr(i, 9)), 3) = brr(d(arr(i, 9)), 3) & "/" & arr(i, 14)
brr(d(arr(i, 9)), 4) = brr(d(arr(i, 9)), 4) & "|" & arr(i, 15)
End If
Next i
Set d = Nothing
ReDim crr(1 To UBound(drr), 1 To UBound(brr, 2))
For j = 2 To UBound(drr)
If drr(j, 1) = brr(j - 1, 1) Then
For k = 2 To UBound(brr, 2)
crr(j - 1, k - 1) = brr(j - 1, k)
Next
End If
Next
Sheets(2).Range("b2:f65536") = ""
Sheets(2).[b2].Resize(UBound(drr) - 1, UBound(brr, 2) - 1) = crr
Application.ScreenUpdating = True
End Sub
|
|