|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.9.14
- Dim wb, arr, sh
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- p = ThisWorkbook.Path & "\拆分后各班情况"
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("补单")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then sht.Delete
- Next
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 23)
- End With
- bt = 5 '//标题行数
- col = 9 '//拆分列号
- For i = bt + 1 To UBound(arr)
- s = arr(i, col)
- If s <> Empty Then
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = Application.Index(arr, i)
- End If
- Next
- For Each k In d.keys
- Set sht = Sheets.Add(After:=Sheets(Sheets.Count))
- m = d(k).Count
- With sht
- .Name = k
- sh.Cells.Copy .[a1]
- .DrawingObjects.Delete
- .[a6].Resize(10000, UBound(arr, 2)) = ""
- .UsedRange.Offset(bt + m).Clear
- .Cells(bt + 1, 1).Resize(m, UBound(arr, 2)) = Application.Rept(d(k).Items, 1)
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|