|
本帖最后由 约定的童话 于 2019-7-26 09:34 编辑
Sub 拆分()
Application.ScreenUpdating = False
Dim i, n, m, k, arr, brr(1 To 1000, 1 To 19), d As Object, t
Set d = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
s = Timer
On Error Resume Next
For i = 2 To UBound(arr)
t = arr(i, 1)
If Not d.exists(t) Then
k = k + 1
d(t) = k
Sheets.Add after:=Sheets("汇总")
ActiveSheet.Name = arr(i, 1)
Sheets("汇总").[a1:t1].Copy ActiveSheet.[a1]
For m = 2 To UBound(arr)
If arr(m, 1) = ActiveSheet.Name Then
n = n + 1
For j = 1 To 19
brr(n, j) = arr(m, j)
Next
End If
Next
ActiveSheet.[a2].Resize(UBound(brr), 19) = brr
n = 0: Erase brr: Sheet1.Select
End If
Next
ss = Timer - s
MsgBox "拆分完毕,耗时:" & ss & "秒", , ""
End Sub
|
|