|
Sub 分组()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Index > 1 Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
r = Cells(Rows.Count, 1).End(xlUp).Row
ar = Range("a1:b" & r)
For i = 1 To UBound(ar) Step 6
m = m + 1
n = 0
ReDim br(1 To 6, 1 To 2)
For s = i To i + 5
If s <= UBound(ar) Then
ar(s, 2) = m & "组"
n = n + 1
For j = 1 To 2
br(n, j) = ar(s, j)
Next j
End If
Next s
If n > 0 Then
Set sht = Sheets.Add(after:=Sheets(Sheets.Count))
sht.Name = m & "组"
sht.[a1].Resize(n, 2) = br
End If
Next i
Sheet1.Range("a1:b" & r) = ar
Application.ScreenUpdating = True
End Sub
|
|