|
- Public Sub abc1()
- Dim d As Object
- Dim ar, i, ii, str, c, k, sht As Worksheet, wbk As Workbook, rng As Range, r
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set wbk = ThisWorkbook
- For Each sht In Sheets
- ar = sht.Range("d1", sht.[iv1].End(1))
- For c = 1 To UBound(ar, 2)
- d(ar(1, c)) = d(ar(1, c)) & " " & sht.Name
- Next
- Next
- k = d.Keys
- For i = 0 To UBound(k)
- Workbooks.Add
- str = Split(Trim(d(k(i))), " ")
- For ii = UBound(str) To 0 Step -1
- ActiveWorkbook.Sheets.Add(before:=ActiveWorkbook.Sheets(1)).Name = str(ii)
- r = wbk.Sheets(str(ii)).[a65536].End(3).Row
- c = wbk.Sheets(str(ii)).[1:1].Find(k(i), , , 1).Column
- Set rng = Union(wbk.Sheets(str(ii)).[a1].Resize(r, 2), wbk.Sheets(str(ii)).Cells(1, c).Resize(r))
- rng.Copy [a1]
- Next
- ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "" & k(i) & ".xls", FileFormat:=xlNormal
- ActiveWorkbook.Close
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|