|
Sub 班级课表()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
With Sheets("总课表")
r = .Cells(Rows.Count, 9).End(xlUp).Row
y = .Cells(1, Columns.Count).End(xlToLeft).Column
If r < 7 Then MsgBox "总课表为空!": End
ar = .Range("i4:cu" & r)
End With
rr = Array(1, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19)
With Sheets("班级课表")
rs = .Cells(Rows.Count, 9).End(xlUp).Row
If rs > 21 Then .Rows("22:" & rs).Delete
k = 1
For i = 4 To UBound(ar)
Erase br
ReDim br(1 To 21, 1 To 6)
y = 0
If ar(i, 1) <> "" Then
For j = 2 To UBound(ar, 2) Step 15
y = y + 1
m = 0
For s = j To j + 14
If s <= UBound(ar, 2) Then
m = m + 1
xh = rr(m - 1)
br(xh, y) = ar(i, s)
End If
Next s
Next j
End If
If k > 1 Then
.Rows("1:21").Copy .Cells(k, 1)
End If
For s = 0 To UBound(rr)
x = rr(s) + k + 1
.Cells(x, 3).Resize(1, 6) = Empty
Next s
.Cells(k, 1) = ar(i, 1) & " 班 课 程 表"
.Cells(k + 2, 3).Resize(UBound(br), UBound(br, 2)) = br
k = k + 21
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|