|
5#
楼主 |
发表于 2016-12-15 13:39:05
|
只看该作者
忘了加上vba,抱歉!
Sub NewSht()
Dim Dic As Object
Dim Arr, Ary, k%, i%, icol%
Set Dic = CreateObject("Scripting.Dictionary")
Arr = Range("A1", [A2000].End(3)(1, 22))
For k = 9 To UBound(Arr)
Dic(Arr(k, 9)) = ""
Next
For Each Key In Dic.keys
If Key <> "" Then
ReDim Ary(0 To UBound(Arr), 1 To 22)
i = -1
For k = 1 To UBound(Arr)
If Arr(k, 9) = Key Or k = 1 Then
i = i + 1
For icol = 1 To 22
Ary(i, icol) = Arr(k, icol)
Next
End If
Next
Workbooks.Add
With ActiveWorkbook
.ActiveSheet.[A1].Resize(i + 1, 22) = Ary
.ActiveSheet.[A1].Resize(i + 1, 22).Borders.LineStyle = 1
.SaveAs ThisWorkbook.Path & "\" & Split(Key, " ")(0) & ".xlsx"
.Close
End With
End If
Next
Dic.RemoveAll
End Sub
|
|