|
Sub 拆分()
Dim arr
Dim ws As Worksheet
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
With Worksheets("8月维修登记")
r = .Cells(.Rows.Count, 2).End(xlUp).Row
arr = .Range("a1:t" & r)
For i = 2 To UBound(arr)
If arr(i, 3) <> "" Then
If Not d.exists(arr(i, 3)) Then
Set d(arr(i, 3)) = .Cells(1, 1).Resize(1, 20)
End If
Set d(arr(i, 3)) = Union(d(arr(i, 3)), .Cells(i, 1).Resize(1, 20))
End If
Next
End With
For Each ws In Worksheets
aa = ws.Name
If d.exists(aa) Then
With ws
d(aa).Copy .Range("a2")
End With
End If
Next
Worksheets("8月维修登记").Activate
Application.ScreenUpdating = True
MsgBox "数据拆分完毕!", vbInformation
End Sub |
|