|
Sub zz()
Dim myPath$, myFile$, Aiv As Workbook, i, n, m, sh, Aiv2 As Workbook
Application.DisplayAlerts = False '¹Ø±ÕÌáʾ´°
Application.ScreenUpdating = False
On Error Resume Next
brr = sh1.Range("A2:H" & sh1.Range("A65536").End(3).Row)
myPath = ThisWorkbook.Path & "\" '°ÑÎļþ·¾¶¶¨Òå¸ø±äÁ¿
myFile = Dir(myPath & "*.xls") 'ÒÀ´ÎÕÒÑ°Ö¸¶¨Â·¾¶ÖеÄ*.xlsÎļþ
n = 0
Do While myFile <> "" 'µ±Ö¸¶¨Â·¾¶ÖÐÓÐÎļþʱ½øÐÐÑ­»·
If myFile <> ThisWorkbook.Name Then
Set Aiv = Workbooks.Open(myPath & myFile) '´ò¿ª·ûºÏÒªÇóµÄÎļþ
m = Aiv.Sheets.Count
If m > n Then
For i = n + 1 To m
Workbooks.Add
ActiveWorkbook.SaveAs Filename:= _
myPath & "½á¹û\±¨±í" & i & ".xlsx"
Next
n = m
End If
For Each sh In Aiv.Sheets
Set Aiv2 = Workbooks(sh.Name & ".xlsx")
sh.Copy After:=Aiv2.Sheets(1) '¸´Öƹ¤×÷±í
Aiv2.Sheets(sh.Name).Name = Mid(Aiv.Name, 1, Len(Aiv.Name) - 4) '¸Ä±íÃû
'
Next
Workbooks(myFile).Close False '¹Ø±ÕÔ´¹¤×÷²¾
End If
myFile = Dir 'ÕÒÑ°ÏÂÒ»¸ö*.xlsÎļþ
Loop
For i = 1 To n
Workbooks("±¨±í" & i & ".xlsx").Sheets("Sheet1").Delete
Workbooks("±¨±í" & i & ".xlsx").Sheets("Sheet2").Delete
Workbooks("±¨±í" & i & ".xlsx").Sheets("Sheet3").Delete
Workbooks("±¨±í" & i & ".xlsx").Close True '¹Ø±Õ±£´æ¹¤×÷²¾
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
|
|