提示:其他語言是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文件; 一列到多列。
  • 粘貼跳過 隱藏/過濾行; 數和總和 按背景顏色; 將個性化電子郵件批量發送給多個收件人。
  • 超級過濾器: 創建高級過濾方案並應用於任何工作表; 分類 按週,日,頻率等; 過濾 通過大膽,公式,評論......
  • 超過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 · 3 months ago
    Minmatar detected :O
  • To post as a guest, your comment is unpublished.
    ali · 6 months ago
    thank you. saved a lot of my time.
  • To post as a guest, your comment is unpublished.
    DragonKing · 6 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 · 4 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