|
Sub 安排考场()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Index > 2 Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
With Sheets("成绩登记")
.[a1].CurrentRegion.Sort .[c1], 2, , , , , , 1 '第一个数据为1,升序排序,为2,降序排序,第二个数据表示标题行数
.[a1].CurrentRegion.Sort .[a1], 1, , , , , , 1 '第一个数据为1,升序排序,为2,降序排序,第二个数据表示标题行数
ar = .[a1].CurrentRegion
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(ar(i, 1)) = ""
End If
Next i
For Each k In d.keys
n = 0
ReDim br(1 To UBound(ar), 1 To 1)
For i = 2 To UBound(ar)
If ar(i, 1) = k Then
n = n + 1
br(n, 1) = n & "." & ar(i, 2)
End If
Next i
Sheets("模板").Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.Name = k & "班"
xh = 3
For i = 1 To n Step 8
xh = xh + 1
lh = 0
For s = i To i + 7
If s <= n Then
lh = lh + 1
.Cells(xh, lh) = br(s, 1)
End If
Next s
Next i
r = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(r, 7) = "打印日期:"
.Cells(r, 8) = Date
.Range("a4:h" & r - 1).Borders.LineStyle = 1
End With
Next k
Application.DisplayAlerts = True
MsgBox "ok!"
End Sub
|
评分
-
2
查看全部评分
-
|