|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each ws In Worksheets
- If ws.Name <> "2026届课表" And ws.Name <> "分班课表" Then
- ws.Delete
- End If
- Next
- With Worksheets("2026届课表")
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- c = .Cells(2, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a2").Resize(r - 1, c)
- End With
- For j = 3 To UBound(arr, 2)
- Worksheets("分班课表").Copy after:=Worksheets(Worksheets.Count)
- ReDim brr(1 To 10, 1 To 5)
- With ActiveSheet
- .Name = arr(1, j)
- For i = 2 To UBound(arr)
- If Len(arr(i, 1)) <> 0 Then
- n = InStr("一二三四五", Right(arr(i, 1), 1))
- End If
- m = InStr("一二三四五六七八九", Mid(arr(i, 2), 2, 1))
- If m > 5 Then
- m = m + 1
- End If
- brr(m, n) = arr(i, j)
- Next
- .Range("c7").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- Next
- End Sub
复制代码 |
|