VBA从工作表另存为工作簿

Sub 宏1()
 Application.ScreenUpdating = False   '屏幕更新关闭
 Application.DisplayAlerts = False    '显示和预警提示关闭
 Dim folder As String   'String字符串
 folder = ThisWorkbook.Path & "\ 班级 "
 If Len(Dir(folder, vbDirectory)) = 0 Then MkDir folder   'vbDirectory文件夹   MkDir创建目录或文件夹
 Dim sht As Worksheet
 For Each sht In Worksheets
 sht.Copy
 ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & sht.Name & ".xls"   '另存在这个路径  名字是工作表名字.xls
 ActiveWorkbook.Close
 Next
 Application.ScreenUpdating = True
 Application.DisplayAlerts = True
End Sub
    原文作者:一蓑烟雨紫洛
    原文地址: https://blog.csdn.net/weixin_34280060/article/details/107984488
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞