|
- Sub qs()
- Application.ScreenUpdating = False: Application.DisplayAlerts = False
- Dim arr, i, dic
- Set d2 = CreateObject("scripting.dictionary")
- brr = Sheet4.UsedRange.Value
- For i = 2 To UBound(brr)
- d2(brr(i, 2)) = "教室" & brr(i, 3) & " 班主任:" & brr(i, 1)
- Next
- arr = Sheet3.UsedRange.Value
- ReDim a(1 To 27, 1 To 4): ReDim b(1 To 27, 1 To 4)
- rw = 32
- For Each k In d2.keys
- m = 0: h = 0: n = 0
- For i = 2 To UBound(arr)
- If k = arr(i, 1) Then
- m = m + 1
- If m Mod 2 Then
- n = n + 1
- For j = 2 To 5
- b(n, j - 1) = arr(i, j)
- Next
- Else
- h = h + 1
- For j = 2 To 5
- a(h, j - 1) = arr(i, j)
- Next
-
- End If
- End If
- Next
- With Sheet1
- .[a1].Value = "2024级" & k & "班"
- .[a2].Value = d2(k)
- .[a4].Resize(27, 9) = Empty
- .[a4].Resize(n, 4) = b: .[f4].Resize(h, 4) = a
- .Rows("1:30").Copy .Range("a" & rw)
- rw = rw + 32
- End With
- Next
- Sheet1.Rows("1:31").Delete
- Set d2 = Nothing
- Application.ScreenUpdating = True: Application.DisplayAlerts = True
- End Sub
复制代码 |
|