admin 管理员组

文章数量: 1086019


2024年3月27日发(作者:抽奖程序代码)

(完整)excel常用代码集合(非常重要)

批量将工作表转换为独立工作簿

Sub Newbooks()

'EH技术论坛.VBA编程学习与实践。看见星光

Dim sht As Worksheet, strPath$

With alog(msoFileDialogFolderPicker)

’选择保存工作薄的文件路径

If 。Show Then

strPath = 。SelectedItems(1)

’读取选择的文件路径

Else

Exit Sub

'如果没有选择保存路径,则退出程序

End If

End With

(完整)excel常用代码集合(非常重要)

If Right(strPath, 1) <〉 ”” Then strPath = strPath & ""

Application。DisplayAlerts = False

'取消显示系统警告和消息,避免重名工作簿无法保存.当有重名工作簿时,会直接覆盖保存。

Application。ScreenUpdating = False

’取消屏幕刷新

For Each sht In Worksheets

’遍历工作表

'复制工作表,工作表单纯复制后,会成为活动工作薄

With ActiveWorkbook

。SaveAs strPath & sht。Name, xlWorkbookDefault

'保存活动工作薄到指定路径下,以默认文件格式

。Close True ’关闭工作薄并保存

End With


本文标签: 工作 保存 路径 选择