|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 拆分工作表()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim d As Object
Dim ar As Variant
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
If sh.Index > 11 Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
With Sheets("总表")
r = .Cells(Rows.Count, 10).End(xlUp).Row
ar = .Range("j1:j" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> Empty Then
If Not d.exists(Trim(ar(i, 1))) Then
Set d(Trim(ar(i, 1))) = .Rows(i)
Else
Set d(Trim(ar(i, 1))) = Union(d(Trim(ar(i, 1))), .Rows(i))
End If
End If
Next i
End With
x = d.keys
For i = 0 To UBound(x)
Sheets("总表").Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.name = x(i)
.UsedRange.Offset(1).Borders.LineStyle = 0
.UsedRange.Offset(1) = Empty
d.items()(i).Copy .[a2]
End With
Next i
Set d = Nothing
Application.ScreenUpdating = False
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|