本帖最后由 zjdh 于 2017-1-25 18:06 编辑
噢,我忘了设置路径啦。
Sub 创建工作薄并按要求命名同高同宽2()
Dim vTimer As Variant
Dim vData As Variant, nCols As Integer, I As Integer, sPath As String
Application.ScreenUpdating = False
vTimer = Timer
Sheets("数据").Copy
With ActiveSheet
vData = .[A2].CurrentRegion.Value
nCols = UBound(vData, 2)
.Rows("4:500").Delete
For I = 3 To UBound(vData)
If vData(I, 1) <> "" Then
.Name = vData(I, 1)
.[A3].Resize(, nCols) = Application.Index(vData, I, 0)
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & vData(I, 1) & ".xlsx", Password:=Right(vData(I, 2), 6)
End If
Next
ActiveWorkbook.Close
End With
Application.ScreenUpdating = True
MsgBox Format(Timer - vTimer, "0.0000s")
End Sub
运行时间由于存储需要时间,是无法缩短的!