|
- Sub test3()
- Dim r%, i%
- Dim arr, brr
- Dim wb As Workbook
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 3).End(xlUp).Row
- c = .Cells(3, .Columns.Count).End(xlToLeft).Column
- arr = .Range("e1:e" & r)
- For i = 4 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = .Range("a1").Resize(3, c)
- End If
- Set d(arr(i, 1)) = Union(d(arr(i, 1)), .Cells(i, 1).Resize(1, c))
- Next
- End With
- Application.SheetsInNewWorkbook = 1
- For Each aa In d.keys
- Set wb = Workbooks.Add
- With wb
- With .Worksheets(1)
- d(aa).Copy .Range("a1")
- End With
- .SaveAs Filename:=ThisWorkbook.Path & "" & aa
- .Close False
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "拆分完毕!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|