|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim ar, i&, dic As Object, vKey, Rng As Range, strPath$, strFileName$
DoApp False
Set dic = CreateObject("Scripting.Dictionary")
With [a1].CurrentRegion
ar = .Value
Set Rng = .Rows("1:4")
For i = 5 To UBound(ar)
If Not dic.exists(ar(i, 14)) Then
Set dic(ar(i, 14)) = Rng
End If
Set dic(ar(i, 14)) = Union(dic(ar(i, 14)), .Rows(i))
Next
End With
strPath = ThisWorkbook.Path & "\"
For Each vKey In dic.keys
strFileName = strPath & vKey
With Workbooks.Add
dic(vKey).Copy
.Sheets(1).[a1].PasteSpecial xlPasteColumnWidths
dic(vKey).Copy .Sheets(1).[a1]
.SaveAs strFileName
.Close
End With
Next
Set dic = Nothing: Set Rng = Nothing
DoApp
Beep
End Sub
Function DoApp(Optional b As Boolean = True)
With Application
.ScreenUpdating = b
.DisplayAlerts = b
.Calculation = -b * 30 - 4135
End With
End Function
|
评分
-
1
查看全部评分
-
|