提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何通过Excel中的行数将数据拆分为多个工作表?

例如,我有一个数据列表的范围,现在我想按行数将它分成多个工作表,在这个例子中,我将按照每个5行分割它(见下面的截图)。 有什么方法可以帮助我们快速解决这个问题吗? 在这里我将介绍两个技巧,让您轻松完成。


DOC-分割数据逐rows1


-2



DOC-分割数据逐rows2
DOC-分割数据逐rows3
DOC-分割数据逐rows4
DOC-分割数据逐rows5

按VBA代码的行数将数据拆分成多个工作表

通过Kutools for Excel将行数据拆分为多个工作表

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel解决了您的大多数问题,并使您的生产率提高了80%
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 与Office 2007-2019和365一起使用; 支持所有语言; 在您的企业或组织中轻松部署。

箭头蓝色右泡 按VBA代码的行数将数据拆分成多个工作表


下面的VBA代码可以帮助您按行数将行拆分成多个工作表,如下所示:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,并将以下代码粘贴到模块窗口中。

VBA:在Excel中按行数拆分数据。

Sub SplitData()
'Updateby20140617
Dim WorkRng As Range
Dim xRow As Range
Dim SplitRow As Integer
Dim xWs As Worksheet
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
SplitRow = Application.InputBox("Split Row Num", xTitleId, 5, Type:=1)
Set xWs = WorkRng.Parent
Set xRow = WorkRng.Rows(1)
Application.ScreenUpdating = False
For i = 1 To WorkRng.Rows.Count Step SplitRow
    resizeCount = SplitRow
    If (WorkRng.Rows.Count - xRow.Row + 1) < SplitRow Then resizeCount = WorkRng.Rows.Count - xRow.Row + 1
    xRow.Resize(resizeCount).Copy
    Application.Worksheets.Add after:=Application.Worksheets(Application.Worksheets.Count)
    Application.ActiveSheet.Range("A1").PasteSpecial
    Set xRow = xRow.Offset(SplitRow)
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

3。 然后按 F5 键来运行代码,弹出一个对话框来选择要分割的范围,然后单击 OK,另一个对话框为你指定行数。 看截图:

4. 点击 OK,并且范围按行数分成多个工作表。

注意:拆分工作表放置在主工作表的后面。


箭头蓝色右泡 通过Kutools for Excel将行数据拆分为多个工作表

上面的代码只能按指定的行数进行分割,如果数据有标题,则不会为每个工作表数据添加标题。

但随着 Kutools for Excel拆分数据,您不仅可以为每个工作表数据插入标题,还可以指定新的拆分工作表名称。

Kutools for Excel 包含了比300更方便的Excel工具。 免费试用30天无限制。 立即获取

如果您已经安装了Kutools for Excel,请按照以下步骤操作:

1。 选择要分割的数据范围。

2。 点击 企业服务 > 工作表工具 > 拆分数据 (或 企业服务 > 拆分数据 ),看截图:

DOC-分割数据逐rows6

3。 在 将数据拆分为多个工作表 对话框:

  • 选择 固定行 低至 根据分割 选项,然后输入要为每个工作表分割的行数。 (如果您的数据包含标题,并且要将其插入到每个新的拆分工作表中,请检查 我的数据有标题 选项。)
  • 然后,您可以指定拆分工作表名称 新的工作表名称 部分,从中选择工作表名称规则 规则 下拉列表中,可以添加 字首 or 后缀 表格名称也是如此。 看截图:

DOC-分割数据逐rows7

4。 指定设置后,点击 OK,并且所选数据已被每个5行分割成新工作簿的多个工作表。 并为每个新的工作表插入标题。 看截图:

DOC-分割数据逐rows8

点击了解更多关于这个拆分数据功能。

相关文章:

如何根据Excel中的列将数据拆分为多个工作表?


Kutools for Excel解决了您的大多数问题,并使您的生产率提高了80%

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能30天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    eve · 2 months ago
    Minmatar detected :O
  • To post as a guest, your comment is unpublished.
    ali · 5 months ago
    thank you. saved a lot of my time.
  • To post as a guest, your comment is unpublished.
    DragonKing · 5 months ago
    Years later, and this still holds up excellently. Thanks!
  • To post as a guest, your comment is unpublished.
    Max · 1 years ago
    Omg thank you so very much dude!
  • To post as a guest, your comment is unpublished.
    prasanna · 1 years ago
    Hi Thanks for this great code, but the concern is, here we can only split fixed number of rows, can you help me with split is based on some name or code, because i have different set of rows for each worksheet.
  • To post as a guest, your comment is unpublished.
    aparna · 2 years ago
    hi this works great but want the output as string how can i modify the code or i can say example : 'output',
  • To post as a guest, your comment is unpublished.
    Ralph · 2 years ago
    Thanks a lot for the fantastic VBA-Script. But how to modify it to keep the header row on every split?
  • To post as a guest, your comment is unpublished.
    Ralph · 2 years ago
    Thanks, for this fantastic VBA-Script. But how to configure it to repeat the header row on every split?
  • To post as a guest, your comment is unpublished.
    Gunesh Chandran · 2 years ago
    Thanks a lot for this tutorial. It is working fine.
  • To post as a guest, your comment is unpublished.
    Adam Dicker · 3 years ago
    Is there a way to split and then exp[ort to multiple HTML files?
  • To post as a guest, your comment is unpublished.
    Amy Takers · 3 years ago
    We can increase rankings of your website in all major search engines at a very affordable price. Email us back to get a full proposal.
  • To post as a guest, your comment is unpublished.
    MattG · 3 years ago
    I've searched endlessly for this. Thank you so much for this tutorial!!!!
  • To post as a guest, your comment is unpublished.
    John Boyd · 4 years ago
    Works great coupled with this one as necessary: http://www.extendoffice.com/documents/excel/628-excel-split-workbook.html
  • To post as a guest, your comment is unpublished.
    Teri · 4 years ago
    It works with one row of column headers. I use multiple rows that include averages and totals. Plus, I have a distribution chart at the bottom. How can I keep these intact? Currently this info is not transferring over to the new worksheets it creates.
  • To post as a guest, your comment is unpublished.
    Teri · 4 years ago
    I have multiple rows of column headers containing averages and totals at the top of each sheet. I have a distribution chart at the bottom. This needs to be kept on each new sheet split out. How do I make this happen with the tool?
  • To post as a guest, your comment is unpublished.
    joms · 5 years ago
    hello,

    its not working for me. my data is coming from a pivot table and it has header. this vba can export some data but not all... pls assist
  • To post as a guest, your comment is unpublished.
    Lijesh · 5 years ago
    Great . It is awesome ...

    Thanks