|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.2.2
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim arr, brr, d
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Dim tm: tm = Timer
- For Each sht In Sheets
- If sht.Name <> "模板" And sht.Name <> "总表" And sht.Name <> "班主任" Then
- sht.Delete
- End If
- Next
- arr = Sheets("班主任").UsedRange
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- d1(s) = arr(i, 2)
- Next
- arr = Sheets("总表").UsedRange
- For i = 3 To UBound(arr)
- s = arr(i, 3)
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- b = [{1,2,4,5,6,7,8,9,10}]
- For Each k In d.keys
- If k <> Empty Then
- Sheets("模板").Copy after:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = 0
- ReDim brr(1 To 100, 1 To 9)
- With sht
- .Name = k
- .[b2] = k: .[i2] = d1(k)
- For Each kk In d(k).keys
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(b)
- brr(m, j) = arr(kk, b(j))
- Next
- Next
- .[a4].Resize(m, 9) = brr
- .UsedRange.Offset(m + 3).Clear
- End With
- End If
- Next
- Sheets("总表").Activate
- Application.ScreenUpdating = False
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|