|
如何获得题目的效果,求老师解答。
- Sub a()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim sh As Worksheet, st As String, wb As Workbook, str As String
- Dim d
- Set d = CreateObject("scripting.dictionary")
- For Each sh In ThisWorkbook.Worksheets
- st = sh.Name
- str = Replace(Right(st, Len(st) - InStr(st, "(")), ")", "")
- If d.exists(str) Then
- sh.Copy after:=Workbooks(str & ".xls").Sheets(Workbooks(str & ".xls").Sheets.Count)
- Workbooks(str & ".xls").Save
- Else
- d(str) = ""
- sh.Copy
- Set wb = ActiveWorkbook
- wb.SaveAs ThisWorkbook.Path & "" & str & ".xls"
- End If
- Next sh
- ThisWorkbook.Save
- Workbooks.Close
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|