|
代码如下。。。
Sub test1212()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("sheet1")
For Each sh In wb.Sheets
If sh.Name <> sht.Name Then sh.Delete '删除其他工作表,请留意!!
Next
r = sht.Cells(Rows.Count, 1).End(3).Row
c = sht.Cells(2, Columns.Count).End(1).Column
Set Rng = sht.[a2].Resize(r - 1, c)
Set d = CreateObject("scripting.dictionary")
arr = Rng
For i = 2 To UBound(arr)
s = arr(i, 1)
If Not d.exists(s) Then
d(s) = ""
End If
Next
For Each Key In d.keys
sht.AutoFilterMode = False
Rng.AutoFilter Field:=1, Criteria1:=Key
sht.Copy after:=wb.Sheets(wb.Sheets.Count)
With ActiveSheet
.Name = Key
.DrawingObjects.Delete
.Cells.ClearContents
sht.UsedRange.SpecialCells(xlCellTypeVisible).Copy .[a1]
End With
Next
Set d = Nothing
sht.AutoFilterMode = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub |
评分
-
1
查看全部评分
-
|