|
- Sub 总表拆分()
- Dim arr, d, i&, x, aa, iRow&, Sh As Worksheet
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Sheets(1).Activate
- iRow = Cells(Rows.Count, 1).End(xlUp).Row
- arr = Range("a3:a" & iRow)
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To UBound(arr)
- x = arr(i, 1)
- d(x) = ""
- Next
- aa = d.keys
- For i = 0 To UBound(aa)
- With Sheets(1).Range("a2:k" & iRow)
- '.Select
- .AutoFilter field:=1, Criteria1:=aa(i)
- End With
- Sheets.Add after:=Sheets(Sheets.Count)
- Set Sh = ActiveSheet
- Sh.Name = aa(i)
- Sheets(1).UsedRange.SpecialCells(xlCellTypeVisible).Copy Sh.[a1]
- Next
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|