|
Sub Macro1()
Dim arr, sht As Worksheet, i&, n&
Set sht = ThisWorkbook.Sheets(1)
arr = Range("a1:c" & Range("a65536").End(xlUp).Row + 1)
n = 1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For i = 2 To UBound(arr)
If arr(i, 1) <> arr(n, 1) Then
With Workbooks.Add
sht.Range(sht.Cells(n, 1), sht.Cells(i - 1, 3)).Copy .Sheets(1).[a1]
ThisWorkbook.Sheets(2).UsedRange.Copy .Sheets(2).[a1]
ThisWorkbook.Sheets(3).UsedRange.Copy .Sheets(3).[a1]
.Sheets(1).Name = "初始数据"
.Sheets(2).Name = "成果数据"
.Sheets(3).Name = "完整数据"
.SaveAs Filename:=ThisWorkbook.Path & "\成果\" & arr(n, 1) & ".xls"
.Close 1
End With
n = i
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
|