|
Sub test()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
With Sheets("收费明细")
y = .Cells(1, Columns.Count).End(xlToLeft).Column + 2
x = .Cells(Rows.Count, 1).End(xlUp).Row
.Range(.Cells(1, 9), .Cells(x, y)).Clear
ar = .[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
d(Trim(ar(i, 2))) = ""
End If
Next i
yy = 9
For Each k In d.keys
m = yy + 1
.Cells(1, yy) = k
For j = 1 To 12
.Cells(1, m) = j
m = m + 1
Next j
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) = k Then
ks = Val(Right(Trim(ar(i, 7)), 2))
js = Val(Right(Trim(ar(i, 8)), 2))
For j = ks To js
.Cells(i, yy + j) = ar(i, 3)
Next j
End If
Next i
yy = yy + 13
Next k
.Range(.Cells(1, 9), .Cells(x, yy - 1)).Borders.LineStyle = 1
End With
End Sub
|
|