|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 拆分()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set sht = Sheets("模板")
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Index > 3 Then sh.Delete
Next sh
Application.DisplayAlerts = True
With Sheets("数据库")
r = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 3 Then MsgBox "数据库为空!": End
ar = .Range("c2:c" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(Trim(ar(i, 1))) = ""
End If
Next i
For Each k In d.keys
sht.Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.Name = k
.[c5] = k
End With
Next k
Sheets("数据库").Select
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|