|
Sub 插入行()
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With ActiveSheet
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "考场信息为空!": End
ar = .Range("a1:d" & r)
.UsedRange.Offset(1, 7) = Empty
For i = 2 To UBound(ar)
If ar(i, 3) <> "" Then
If Not d.exists(ar(i, 3)) Then Set d(ar(i, 3)) = CreateObject("scripting.dictionary")
d(ar(i, 3))(i) = ""
End If
Next i
m = 2
For Each k In d.keys
n = 0
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
For Each kk In d(k).keys
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(kk, j)
Next j
Next kk
.Cells(m, 8).Resize(n, UBound(br, 2)) = br
m = m + 15
Next k
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|