|
Sub zdkb()
Dim i, j, jj, k, x, y, m, n, p, irow, icolumn
Dim ar, br, cr
Dim d As Object
Set d = CreateObject("scripting.dictionary")
x = Val(InputBox("请从2301-2334中选择一个输入生成课表的班级号: "))
If Len(x) <> 4 Then
Exit Sub
End If
irow = Sheet1.[a65536].End(xlUp).Row
icolumn = Sheet1.[iv2].End(xlToLeft).Column
ar = Sheet1.[a1].Resize(irow, icolumn)
y = (icolumn - 1) / 10
For i = 3 To irow
If ar(i, 1) = x Then
For j = 1 To y
For jj = 10 * j - 8 To 10 * j + 1
d(ar(1, 10 * j - 8) & ar(2, jj)) = ar(i, jj)
Next
Next
Exit For
End If
Next
With Sheet2
.[c6].Resize(10, 7).ClearContents
.[c1] = x & "班课程表"
irow = .[b65536].End(xlUp).Row
icolumn = .[iv3].End(xlToLeft).Column
ReDim br(1 To irow - 8, 1 To icolumn - 2)
For n = 6 To irow - 3
p = p + 1
For m = 3 To icolumn
If d(.Cells(3, m).Value & .Cells(n, 2).Value) = 0 Then
br(p, m - 2) = ""
Else
br(p, m - 2) = d(.Cells(3, m).Value & .Cells(n, 2).Value)
End If
Next
Next
.[c6].Resize(UBound(br), UBound(br, 2)) = br
End With
MsgBox "ok"
End Sub |
|