|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按订单保存为工作簿()
tms = Timer
Set Rng = Range("A1:U5")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
arr = Range("a1:bq" & Range("a65536").End(xlUp).Row)
Set d = CreateObject("scripting.dictionary")
For i = 6 To UBound(arr)
If Trim(arr(i, 3)) <> "" Then
If Not d.exists(arr(i, 3)) Then
Set d(arr(i, 3)) = Cells(i, 1).Resize(1, 21)
Else
Set d(arr(i, 3)) = Union(d(arr(i, 3)), Cells(i, 1).Resize(1, 21))
End If
End If
Next
k = d.keys
t = d.items
For i = 0 To d.Count - 1
Set wb = Workbooks.Add(xlWBATWorksheet)
With wb.Sheets(1)
Rng.Copy .[a1]: t(i).Copy .[a6]
For j = 1 To UBound(arr, 2)
.Columns(j).ColumnWidth = ThisWorkbook.ActiveSheet.Columns(j).ColumnWidth
Next
For m = 3 To UBound(arr)
.Rows(m).RowHeight = 24
Next
End With
wb.SaveAs Filename:=ThisWorkbook.Path & "\" & k(i), FileFormat:=51
wb.Close
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "完毕!用时" & Format(Timer - tms, "0.00") & "秒"
End Sub
|
评分
-
1
查看全部评分
-
|