|
总表拆分为多表,原格式
- Sub ykcbf() '//2024.7.4
- Dim arr, brr, d
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("成绩表")
- bt = 1
- For Each sht In Sheets
- If sht.Name <> sh.Name Then sht.Delete
- Next
- arr = sh.UsedRange
- For i = bt + 1 To UBound(arr)
- s = arr(i, 3) '//按班级拆分
- If s <> Empty Then
- If Not d.Exists(s) Then
- Set d(s) = CreateObject("scripting.dictionary")
- End If
- d(s)(i) = Application.Index(arr, i)
- End If
- Next i
- For Each k In d.keys
- sh.Copy after:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = d(k).Count
- With sht
- .Name = k
- .UsedRange.Offset(m + bt).Clear
- .DrawingObjects.Delete
- .Cells(bt + 1, 1).Resize(m, UBound(arr, 2)) = Application.Rept(d(k).Items, 1)
- End With
- Next k
- sh.Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|