|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Dim arr, brr, d As Object, i&, j&, k&, x$
- Set d = CreateObject("scripting.dictionary")
- arr = Range("a1").CurrentRegion
- Range("a2:q" & UBound(arr)).ClearContents
- For i = 2 To UBound(arr)
- x = arr(i, 1) & "," & arr(i, 5) & "," & arr(i, 9) & "," & arr(i, 10) & "," & arr(i, 14)
- d(x) = d(x) & "," & arr(i, 7)
- Next
- ReDim brr(1 To d.Count, 1 To UBound(arr, 2))
- a = d.keys: b = d.items
- For j = 0 To d.Count - 1
- m = Split(b(j), ",")
- For i = 2 To UBound(arr)
- x = arr(i, 1) & "," & arr(i, 5) & "," & arr(i, 9) & "," & arr(i, 10) & "," & arr(i, 14)
- If a(j) = x Then
- For k = 1 To UBound(arr, 2)
- brr(j + 1, k) = arr(i, k)
- Next
- brr(j + 1, 7) = IIf(m(0) = "", m(1), m(0))
- brr(j + 1, 6) = Right(brr(j + 1, 7), 2)
- brr(j + 1, 8) = m(UBound(m))
- End If
- Next
- Next
- Range("a2").Resize(UBound(brr), UBound(brr, 2)) = brr
复制代码 |
|