|
請測試看看,謝謝
Sub test()
Dim Arr, i%, xD
Application.ScreenUpdating = False: Application.DisplayAlerts = False
Arr = Sheets(1).[a1].CurrentRegion
Set xD = CreateObject("Scripting.Dictionary")
For i = 2 To UBound(Arr)
If xD.exists(Arr(i, 4)) Then
Set xD(Arr(i, 4)) = Union(xD(Arr(i, 4)), Rows(i))
Else
Set xD(Arr(i, 4)) = Union(Rows(1), Rows(i))
End If
Next
For i = 0 To xD.Count - 1
Workbooks.Add
With ActiveWorkbook
xD.items()(i).Copy .Sheets(1).[a1]
.SaveAs ThisWorkbook.Path & "/" & xD.keys()(i)
.Close
End With
Next
MsgBox "完成"
Application.ScreenUpdating = True: Application.DisplayAlerts = True
End Sub
|
|