|
- Private Sub CommandButton1_Click()
- tms = Timer
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> ActiveSheet.Name Then sht.Delete
- Next
- Application.DisplayAlerts = True
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- m = UBound(arr): n = UBound(arr, 2)
- For i = 5 To m
- If Not d.exists(arr(i, 4)) Then
- Set d(arr(i, 4)) = Range("a" & i).Resize(1, n)
- Else
- Set d(arr(i, 4)) = Union(d(arr(i, 4)), Range("a" & i).Resize(1, n))
- End If
- Next
- x = d.keys
- For k = 0 To UBound(x)
- Set sht = ActiveWorkbook.Sheets.Add(, after:=ActiveSheet)
- sht.Name = x(k)
- d.items()(k).Copy sht.[a5]
- Rows("1:4").Copy sht.[a1]
- Next
- Application.ScreenUpdating = True
- MsgBox Format(Timer - tms, "拆分完成,共耗时:0.00秒")
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|