|
- Private Sub CommandButton1_Click()
- tms = Timer
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = ActiveSheet.UsedRange
- m = UBound(arr): n = UBound(arr, 2)
- Set Rng = [a1].Resize(3, n)
- For i = 4 To m
- If Not d.exists(arr(i, 13)) Then
- Set d(arr(i, 13)) = Range("a" & i).Resize(1, n)
- Else
- Set d(arr(i, 13)) = Union(d(arr(i, 13)), 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.[a4]
- Rng.Copy sht.[a1]
- Next
- Application.ScreenUpdating = True
- MsgBox Format(Timer - tms, "拆分完成,共耗时:0.00秒")
- End Sub
复制代码 |
|