跳到主要内容

如何在Excel中将每个工作表导出并另存为单独的新工作簿?

假设您要导出一个或多个工作表并将其另存为新工作簿,您将如何处理? 通常,您可以复制每个工作表并粘贴到新工作簿中。 但是在这里,我们为您带来一些方便的技巧来应对它:

使用“移动”或“复制”命令将工作表导出并保存为新工作簿

使用VBA代码将工作表导出并保存为新工作簿

使用 Kutools for Excel 导出工作表并将其保存为新工作簿 好主意3


箭头蓝色右气泡 使用“移动”或“复制”命令将工作表导出并保存为新工作簿

使用 移动或复制 命令将帮助您快速将一个或多个工作表导出或复制到新工作簿。

步骤1:在选项卡栏中选择工作表名称。 您可以按住多个选择 按Ctrl 键或 转移 键。

步骤2:右键单击工作表名称,然后单击 移动或复制 从上下文菜单中。
doc导出表1

步骤3: 移动或复制 对话框中,选择 (新书) 的下拉列表中的项目 将选定的图纸移到书.

doc导出表2

步骤4:然后点击 OK,现在您已切换到 新工作簿 与导出或复制的工作表,单击 文件 > 保存 保存新的工作簿。

请注意:移动或复制 对话框中,有一个 建立副本 选项。 如果您不选中它,它将把选定的工作表移出原始工作簿。 如果选中它,它将复制所选的工作表。


快速将多个工作表拆分为Excel中的单独工作簿

在Microsoft Excel中,可以通过将工作表复制并粘贴到新工作簿中,将一个工作簿中的工作表保存或拆分为新的Excel文件。 如果要将大工作簿的每个工作表/工作表拆分为单独的Excel,txt,csv,pdf文件,这似乎很麻烦。 但是随着 Kutools for Excel拆分工作簿 实用程序,您可以快速处理它。  点击即可免费试用 30 天,享受全部功能!
doc拆分工作簿1
 
Kutools for Excel:拥有300多个便捷的Excel加载项,可以在30天内免费试用。

箭头蓝色右气泡 使用VBA代码将工作表导出并保存为新工作簿

下面的代码将导出新工作簿中的所有可见工作表,并将工作表和原始工作表的名称保存在与活动工作簿相同路径的新创建的文件夹中。 请执行以下步骤:

步骤1:按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

步骤2:点击 插页 > 模块,然后将以下宏粘贴到“模块窗口”中:

VBA:将工作表导出并保存为新工作簿,并保存在新文件夹中。

Sub SplitWorkbook()
'Updateby20200806
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim xWs As Worksheet
Dim xWb As Workbook
Dim xNWb As Workbook
Dim FolderName As String
Application.ScreenUpdating = False
Set xWb = Application.ThisWorkbook

DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = xWb.Path & "\" & xWb.Name & " " & DateString

If Val(Application.Version) < 12 Then
    FileExtStr = ".xls": FileFormatNum = -4143
Else
    Select Case xWb.FileFormat
        Case 51:
            FileExtStr = ".xlsx": FileFormatNum = 51
        Case 52:
            If Application.ActiveWorkbook.HasVBProject Then
                FileExtStr = ".xlsm": FileFormatNum = 52
            Else
                FileExtStr = ".xlsx": FileFormatNum = 51
            End If
        Case 56:
            FileExtStr = ".xls": FileFormatNum = 56
        Case Else:
            FileExtStr = ".xlsb": FileFormatNum = 50
        End Select
End If

MkDir FolderName

For Each xWs In xWb.Worksheets
On Error GoTo NErro
    If xWs.Visible = xlSheetVisible Then
    xWs.Select
    xWs.Copy
    xFile = FolderName & "\" & xWs.Name & FileExtStr
    Set xNWb = Application.Workbooks.Item(Application.Workbooks.Count)
    xNWb.SaveAs xFile, FileFormat:=FileFormatNum
    xNWb.Close False, xFile
    End If
NErro:
    xWb.Activate
Next

    MsgBox "You can find the files in " & FolderName
    Application.ScreenUpdating = True
End Sub

步骤3:按下 F5 运行此代码的关键。 然后将弹出一个提示框,告诉您新导出的工作簿的位置,并且原始工作簿的所有工作表都已导出到一些新的单独工作簿中,这些工作簿在新的特定文件夹中命名了原始工作表。 查看屏幕截图:

doc导出表7

箭头蓝色右气泡 使用 Kutools for Excel 导出工作表并将其保存为新工作簿

如果需要将多个工作表另存为单独的工作簿,则第一种方法不是一个好的选择。 对于Excel初学者来说,VBA代码可能有点复杂。 在这里您可以使用 拆分工作簿 实用程序 Kutools for Excel 以快速轻松地导出和保存一个工作簿的每个工作表以分离新工作簿。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

免费安装 Kutools for Excel,请执行以下操作:

步骤1:点击 Kutools 加 > 工作簿 > 拆分工作簿…。 看截图:
doc导出表3

步骤2: 拆分工作簿 对话框,请执行以下操作:

doc导出表4
1: 默认情况下,所有工作表名称都已选中,如果您不想拆分某些工作表,则可以取消选中它们;


2: 如果要避免拆分隐藏的工作表或空白工作表,可以检查 跳过隐藏的工作表 or 跳过空白工作表);


3: 你也可以检查 指定保存 格式,并选择拆分工作表,然后以默认格式另存为文本文件,pdf文件或csv文件,如果不选中此选项,它将拆分工作表并另存为工作簿。

步骤3:然后点击 分裂 按钮,然后选择要将新工作簿放入的文件夹。 看截图:
doc导出表6

步骤4:然后点击 OK,然后在 拆分工作簿 对话框被导出并保存为单独的工作簿。 每个新工作簿均以原始工作表名称命名。 看截图:
doc导出表5

单击以了解有关此拆分工作簿工具的更多信息.

箭头蓝色右气泡 导出并将每个工作表另存为新工作簿


根据Excel中的列或固定行将数据快速拆分为多个工作表

假设您有一个工作表,其中的数据在A到G列中,推销员的名字在A列中,并且您需要根据同一工作簿中的A列将这些数据自动拆分为多个工作表,并且每个推销员都会被拆分为一个新的工作表。 Kutools for Excel分割日期 实用程序可以帮助您根据选定的列快速将数据分为多个工作表,如Excel中显示的屏幕截图所示。  点击获取全功能 30 天免费试用!
doc分割资料2
 
Kutools for Excel:拥有300多个便捷的Excel加载项,可以在30天内免费试用。

相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!

Comments (63)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thanks, this was awesome. There are dozens of pages on the internet talking about how to do this. You guys are the only ones that got the VBA code right. Many thanks. I had a big monster workbook with about 100 tabs, all relatively small, and the VBA macro knocked it out in about five minutes. Thank God for smart guys like you. :)
Rated 5 out of 5
This comment was minimized by the moderator on the site
This has been extremely helpful, my job was doing some data management manually and this helped me automate it. I do have a question though, as the code is a bit over my head to figure out on my own.

What would I need to change to make it so that it always saves as a CSV file instead of an excel file? I know it'll be part of the IF VAL THEN CASES but I don't follow the formatting of that area.

Thank you,
Matt
This comment was minimized by the moderator on the site
Hi, Matt, I am glad that this article can help you. If you want to save sheets as new CSV files, this article https://www.extendoffice.com/documents/excel/5537-excel-batch-convert-to-csv.html lists the methods on exporting sheets as separated CSV files, hope it can do you a favor.
This comment was minimized by the moderator on the site
I have been using this VBA Code for some time and it worked like a charm until I changed computers. I have the same version of excel but now I am getting a Run Time Error "76" Path Not found. Any ideas what could be causing this? It looks like it is hanging up at MkDir. Any help you can provide is appreciated.
This comment was minimized by the moderator on the site
Hi, can I ask which office version you use?
This comment was minimized by the moderator on the site
I'm having this issue as well. I ran it once a month ago just fine and this came up just now.
This comment was minimized by the moderator on the site
You are amazing! Thank you so very much!
This comment was minimized by the moderator on the site
Thank you so much ! great and useful.
This comment was minimized by the moderator on the site
For Each xWs In xWb.Worksheets
How to do export only selected / grouped sheets to separate excel sheets by using this code.?
This comment was minimized by the moderator on the site
Hi there,

Keep getting a pop up that says 'compile error, invalid outside procedure' when i try and run the code. Any thoughts? Thanks for all your help.
This comment was minimized by the moderator on the site
Hi, Issybeee, I have update the VBA code in the tutorial, you can try the new one again.
This comment was minimized by the moderator on the site
For those of you who save macros in your "Personal.XLSB" or XLSTART (I see more questions below related to this), change the line

Set xWb = Application.ThisWorkbook to

Set xWB = ActiveWorkbook

That will make the macro run from the Active Workbook instead and save in a subfolder to that.
This comment was minimized by the moderator on the site
With the first method, if I hit F5, it opens a pop up window with the function "Go to". My excel is in spanish, im not sure if that is a factor. Any idea on how to fix it?
This comment was minimized by the moderator on the site
You can directly click the Run button of the Microsoft Visual Basic for Applications window.
This comment was minimized by the moderator on the site
Un aporte realmente útil. He probado el módulo con código VBA y funciona a la perfección. Muchas gracias, me has salvado una tarea que me hubiera llevado mucho tiempo con el mover y copiar.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations