|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- If r Mod 2 = 1 Then
- r = r + 1
- End If
- arr = .Range("a3:ae" & r)
- End With
- For i = 3 To UBound(arr) Step 2
- If Not d.exists(arr(i, 3)) Then
- ReDim brr(1 To 34)
- brr(1) = arr(i, 21)
- brr(2) = arr(i, 3)
- brr(3) = arr(i, 11)
- Else
- brr = d(arr(i, 3))
- End If
- For j = 1 To UBound(arr, 2)
- If Len(arr(i + 1, j)) <> 0 Then
- sj1 = Left(arr(i + 1, j), 5)
- sj2 = Right(arr(i + 1, j), 5)
- If sj1 = sj2 Then
- brr(j + 3) = sj1
- Else
- brr(j + 3) = sj1 & vbLf & sj2
- End If
- End If
- Next
- d(arr(i, 3)) = brr
- Next
- With Worksheets("sheet2")
- .UsedRange.Offset(1, 0).ClearContents
- .Range("a2").Resize(d.Count, UBound(brr)) = Application.Transpose(Application.Transpose(d.items))
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("a1:ag" & r).Borders.LineStyle = xlContinuous
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|