메인 컨텐츠로 가기

Excel에서 큰 테이블을 여러 개의 작은 테이블로 분할하는 방법은 무엇입니까?

여러 열과 수백 또는 수천 개의 행 데이터가 포함 된 큰 워크 시트가있는 경우 이제이 큰 테이블을 열 값 또는 행 수에 따라 여러 개의 작은 테이블로 분할하여 다음 결과를 얻을 수 있습니다. Excel에서이 작업을 어떻게 처리 할 수 ​​있습니까?

메인 테이블   열 값을 기준으로 테이블을 여러 테이블로 분할 행 수를 기준으로 테이블을 여러 테이블로 분할

VBA 코드를 사용하여 열 값을 기반으로 큰 테이블을 여러 테이블로 분할

VBA 코드를 사용하여 특정 행 수를 기반으로 큰 테이블을 여러 테이블로 분할

놀라운 기능으로 열 값 또는 행 수를 기반으로 큰 테이블을 여러 테이블로 분할


VBA 코드를 사용하여 열 값을 기반으로 큰 테이블을 여러 테이블로 분할

이 큰 테이블을 특정 열 값을 기반으로 여러 테이블로 분할하려면 다음 VBA 코드가 도움이 될 수 있습니다. 다음과 같이하십시오 :

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 큰 테이블을 키 열별로 여러 테이블로 분할합니다.

Sub Splitdatabycol()
'by Extendoffice
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
Dim xTRg As Range
Dim xVRg As Range
Dim xWSTRg As Worksheet
On Error Resume Next
Set xTRg = Application.InputBox("Please select the header rows:", "Kutools for Excel", "", Type:=8)
If TypeName(xTRg) = "Nothing" Then Exit Sub
Set xVRg = Application.InputBox("Please select the column you want to split data based on:", "Kutools for Excel", "", Type:=8)
If TypeName(xVRg) = "Nothing" Then Exit Sub
vcol = xVRg.Column
Set ws = xTRg.Worksheet
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
title = xTRg.AddressLocal
titlerow = xTRg.Cells(1).Row
icol = ws.Columns.Count
ws.Cells(1, icol) = "Unique"
Application.DisplayAlerts = False
If Not Evaluate("=ISREF('xTRgWs_Sheet!A1')") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = "xTRgWs_Sheet"
Else
Sheets("xTRgWs_Sheet").Delete
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = "xTRgWs_Sheet"
End If
Set xWSTRg = Sheets("xTRgWs_Sheet")
xTRg.Copy
xWSTRg.Paste Destination:=xWSTRg.Range("A1")
ws.Activate
For i = (titlerow + xTRg.Rows.Count) To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
ws.Columns(icol).Clear
For i = 2 To UBound(myarr)
ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
xWSTRg.Range(title).Copy
Sheets(myarr(i) & "").Paste Destination:=Sheets(myarr(i) & "").Range("A1")
ws.Range("A" & (titlerow + xTRg.Rows.Count) & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A" & (titlerow + xTRg.Rows.Count))
Sheets(myarr(i) & "").Columns.AutoFit
Next
xWSTRg.Delete
ws.AutoFilterMode = False
ws.Activate
Application.DisplayAlerts = True
End Sub

3. 코드를 붙여 넣은 후 F5 키를 눌러이 코드를 실행하면 프롬프트 상자가 나타납니다. 데이터에서 헤더 행을 선택하십시오. 스크린 샷을 참조하십시오.

4. 그런 다음 OK, 다른 대화 상자가 나타나면 테이블을 분할 할 열 데이터를 선택하십시오. 스크린 샷을 참조하십시오.

5. 딸깍 하는 소리 OK,이 큰 테이블은 마스터 시트 뒤에있는 열 값에 의해 여러 워크 시트로 분할되었습니다. 그리고 새 워크 시트의 이름은 열 값으로 지정됩니다. 스크린 샷보기 :


VBA 코드를 사용하여 특정 행 수를 기반으로 큰 테이블을 여러 테이블로 분할

행 수에 따라 테이블을 여러 테이블로 분할해야하는 경우 다음 VBA 코드가 도움이 될 수 있습니다.

1. 누르고 ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 행 수에 따라 큰 테이블을 여러 테이블로 분할합니다.

Sub Splitdatabyrows()
'Updated by Extendoffice 
Dim WorkRng As Range
Dim xRow As Range
Dim SplitRow As Integer
Dim xWs As Worksheet
Dim xTRg As Range
Dim xNTRg As Range
Dim xIER
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set xTRg = Application.InputBox("Please select the header row:", xTitleId, "", Type:=8)
If TypeName(xTRg) = "Nothing" Then Exit Sub
Set WorkRng = Application.InputBox("Please select the data range(exclude the header row):", xTitleId, WorkRng.Address, Type:=8)
If TypeName(WorkRng) = "Nothing" Then Exit Sub
SplitRow = Application.InputBox("Split Row Num", xTitleId, Type:=1)
If SplitRow = 0 Then Exit Sub
Set xWs = WorkRng.Parent
Set xRow = WorkRng.Rows(1)
xIER = WorkRng.Rows.Count
xIER = WorkRng.Row + xIER - 1
Application.ScreenUpdating = False
For i = 1 To WorkRng.Rows.Count Step SplitRow
    resizeCount = SplitRow
    If (xIER - xRow.Row + 1) < SplitRow Then
        resizeCount = (xIER - xRow.Row + 1)
    End If
    xRow.Resize(resizeCount).Copy
    Set xWs = Application.Worksheets.Add(after:=Application.Worksheets(Application.Worksheets.Count))
    If xIER > (xRow.Row + SplitRow - 1) Then
        xWs.Name = xRow.Row & " - " & (xRow.Row + SplitRow - 1)
    ElseIf xIER = xRow.Row Then
        xWs.Name = xRow.Row
    Else
        xWs.Name = xRow.Row & " - " & xIER
    End If
    Application.ActiveSheet.Range("A1").PasteSpecial
    Set xNTRg = Application.ActiveSheet.Range("A1")
    xTRg.Copy
    xNTRg.Insert
    Set xRow = xRow.Offset(SplitRow)
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

3. 그런 다음, F5 키, 팝업 대화 상자에서 헤더 행을 선택하고 스크린 샷을 참조하십시오.

4. 그런 다음 OK두 번째 프롬프트 상자에서 행 수로 분할 할 데이터 범위를 선택합니다. 스크린 샷을 참조하십시오.

5. 그런 다음 OK 버튼을 누르고 세 번째 프롬프트 상자에 분할 할 행 수를 입력합니다. 스크린 샷을 참조하십시오.

6. 그런 다음 OK 버튼을 클릭하면 아래 스크린 샷과 같이 마스터 테이블이 행 수에 따라 여러 워크 시트로 분할되었습니다.


놀라운 기능으로 열 값 또는 행 수를 기반으로 큰 테이블을 여러 테이블로 분할

위의 코드는 대부분의 사용자에게 어려울 수 있습니다. 여기서 놀라운 기능을 소개합니다.데이터 분할 of Excel 용 Kutools. 이 유틸리티를 사용하면 키 열 또는 행 수에 따라 큰 테이블을 여러 테이블로 빠르고 쉽게 분할 할 수 있습니다.

팁 :이것을 적용하려면 데이터 분할 먼저 기능을 다운로드해야합니다. Excel 용 Kutools을 클릭 한 다음 기능을 빠르고 쉽게 적용하십시오.

설치 후 Excel 용 Kutools, 다음과 같이하십시오.

1. 분할 할 데이터 범위를 선택한 다음 쿠툴즈 플러스 > 데이터 분할, 스크린 샷 참조 :

2. 에서 데이터를 여러 워크 시트로 분할 대화 상자에서 필요에 따라 설정을 지정합니다.

(1.) 선택 특정 열 or 고정 행 인사말 기준 분할 필요한 섹션;

(2.) 새 워크 시트 이름을 지정합니다. 규칙 드롭 다운 목록에서 접두사 or 접미사 시트 이름에도 적용됩니다.

3. 그런 다음 Ok 이제 큰 테이블이 새 통합 문서에서 여러 개의 작은 테이블로 분할되었습니다. 스크린 샷보기 :

열 값을 기준으로 테이블을 여러 테이블로 분할 행 수를 기준으로 테이블을 여러 테이블로 분할

Excel 용 Kutools 및 무료 평가판을 지금 다운로드하려면 클릭하십시오!


더 많은 관련 기사 :

  • Excel에서 Excel 파일을 분리하기 위해 통합 문서 분할
  • 통합 문서의 각 워크 시트를 개별 Excel 파일로 저장하여 큰 통합 문서를 별도의 Excel 파일로 분할해야 할 수 있습니다. 예를 들어 통합 문서를 여러 개의 개별 Excel 파일로 분할 한 다음 각 파일을 다른 사람에게 전달하여 처리 할 수 ​​있습니다. 이렇게하면 특정 사람이 특정 데이터를 처리하고 데이터를 안전하게 유지할 수 있습니다. 이 기사에서는 큰 통합 문서를 각 워크 시트에 따라 별도의 Excel 파일로 분할하는 방법을 소개합니다.
  • Excel에서 전체 이름을 성과 이름으로 분할
  • 첫 번째 스크린 샷이 아래의 단일 열에 표시된 것처럼 이름 명단이 있다고 가정하고 다음 스크린 샷과 같이 전체 이름을 이름 열, 중간 이름 열 및 성 열로 분할해야합니다. 이 문제를 해결하는 데 도움이되는 몇 가지 까다로운 방법이 있습니다.
  • Excel에서 긴 열을 여러 열로 분할
  • Excel에 긴 열 데이터가 있으면 볼 때 번거로울 것입니다. 그러나 이제는 Excel에서 이러한 긴 목록을 여러 열로 분할 할 수 있으면 편리하게 볼 수 있습니다.

 


  • 슈퍼 포뮬러 바 (여러 줄의 텍스트와 수식을 쉽게 편집 할 수 있습니다.) 레이아웃 읽기 (많은 수의 셀을 쉽게 읽고 편집합니다.) 필터링 된 범위에 붙여 넣기...
  • 셀 / 행 / 열 병합 및 데이터 보관; 셀 내용 분할; 중복 행과 합계 / 평균 결합... 중복 셀 방지; 범위 비교...
  • 중복 또는 고유 선택 행; 빈 행 선택 (모든 셀이 비어 있음); 슈퍼 찾기 및 퍼지 찾기 많은 통합 문서에서; 무작위 선택 ...
  • 정확한 사본 수식 참조를 변경하지 않고 여러 셀; 참조 자동 생성 여러 시트에; 글 머리 기호 삽입, 확인란 등 ...
  • 즐겨 찾기 및 빠른 수식 삽입, 범위, 차트 및 그림; 셀 암호화 암호로; 메일 링리스트 생성 이메일 보내기 ...
  • 텍스트 추출, 텍스트 추가, 위치 별 제거, 공간 제거; 페이징 부분합을 만들고 인쇄합니다. 셀 내용과 주석 간 변환...
  • 슈퍼 필터 (다른 시트에 필터 구성표 저장 및 적용) 고급 정렬 월 / 주 / 일, 빈도 등 특수 필터 굵은 기울임 꼴로 ...
  • 통합 문서와 워크 시트 결합; 키 열을 기반으로 테이블 병합; 데이터를 여러 시트로 분할; xls, xlsx 및 PDF 일괄 변환...
  • 피벗 테이블 그룹화 기준 주 번호, 요일 등 ... 잠금 해제되고 잠긴 셀 표시 다른 색상으로; 수식 / 이름이있는 셀 강조 표시...
kte 탭 201905
  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
officetab 하단

 

Comments (13)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank you very much.....
This comment was minimized by the moderator on the site
Super Sache

Frage:

Ist es möglich die Tabelle immer neu zu füllen und neu zu berechnen.
Bin absoluter anfänger. :-)
Danke im Voraus
This comment was minimized by the moderator on the site
Hello, Lukas,
I'm sorry, the methods in this article can't support to update the new data when the original data is changed.
So, you need to run the code again to get the latest data if there are changes in your data.
Thank you!
This comment was minimized by the moderator on the site
I can't get this macro to work (Split A Large Table Into Multiple Tables Based On Column Value With VBA Code)
My table has 5 columns and 639,165 rows. Is it too big?
This comment was minimized by the moderator on the site
Hello, Rebekah

If the data is too large, the code will not work perfectly.
Here, I recommend our Kutools for Excel' Split Data feature for you. With this feature, you can split large data to multiple sheets quickly and easily.
You can try it for 30 days freely. Please download it ffrom: https://www.extendoffice.com/download/kutools-for-excel.html
Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hallo zusammen. Ich habe das gleiche Problem wie cGast - gibt es dazu eine Lösung?
This comment was minimized by the moderator on the site
Hi, Miriam,

The VBA code has been updated to a new one in this article, please try it again, if you have any other problem, please comment here. Thank you!
This comment was minimized by the moderator on the site
I tried "Split a large table into multiple tables based on the specific number of rows with VBA code" with my data of 103,000 rows split in groups of 15000 which should have returned 8 sheets, however it didnt work, it just produced 8 sheets with the headers only. but it does work when i use it with less that 10000rows. any help there?
This comment was minimized by the moderator on the site
Hello cguest,
Yes, as you said, the VBA code does not work correctlly when there are lots of data, here, I provide a new code, please try:
Sub Splitdatabyrows()
'Updated by Extendoffice 
Dim WorkRng As Range
Dim xRow As Range
Dim SplitRow As Integer
Dim xWs As Worksheet
Dim xTRg As Range
Dim xNTRg As Range
Dim xIER
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection


Set xTRg = Application.InputBox("Please select the header row:", xTitleId, "", Type:=8)
If TypeName(xTRg) = "Nothing" Then Exit Sub
Set WorkRng = Application.InputBox("Please select the data range(exclude the header row):", xTitleId, WorkRng.Address, Type:=8)
If TypeName(WorkRng) = "Nothing" Then Exit Sub


SplitRow = Application.InputBox("Split Row Num", xTitleId, Type:=1)
If SplitRow = 0 Then Exit Sub

Set xWs = WorkRng.Parent
Set xRow = WorkRng.Rows(1)
xIER = WorkRng.Rows.Count
xIER = WorkRng.Row + xIER - 1


Application.ScreenUpdating = False
For i = 1 To WorkRng.Rows.Count Step SplitRow
    resizeCount = SplitRow
    If (xIER - xRow.Row + 1) < SplitRow Then
        resizeCount = (xIER - xRow.Row + 1)
    End If
    xRow.Resize(resizeCount).Copy
    Set xWs = Application.Worksheets.Add(after:=Application.Worksheets(Application.Worksheets.Count))
    If xIER > (xRow.Row + SplitRow - 1) Then
        xWs.Name = xRow.Row & " - " & (xRow.Row + SplitRow - 1)
    ElseIf xIER = xRow.Row Then
        xWs.Name = xRow.Row
    Else
        xWs.Name = xRow.Row & " - " & xIER
    End If
    Application.ActiveSheet.Range("A1").PasteSpecial
    Set xNTRg = Application.ActiveSheet.Range("A1")
    xTRg.Copy
    xNTRg.Insert
    Set xRow = xRow.Offset(SplitRow)
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub


Hope it can help you, Thank you!
This comment was minimized by the moderator on the site
"Teilen Sie eine große Tabelle basierend auf der spezifischen Anzahl von Zeilen mit VBA-Code in mehrere Tabellen auf"Funktioniert echt Super. Ist es möglich dass auch Verbundene Zellen erkannt und die Anzahl der Zeilen entsprechend angepasst wird so dass die Verbundenen Zellen beim Seitenumbruch nicht getrennt werden?
This comment was minimized by the moderator on the site
Если разбиваете по строкам и строк больше, чем 32 767 то поменяйте тип данных у переменных xIER и SplitRow с Integer на Long
This comment was minimized by the moderator on the site
Ich habe die erste Variante mit 456.913 Zeilen und 8 Spalten probiert - leider ohne dass irgendwas ausgeführt wurde.
This comment was minimized by the moderator on the site
Всем привет. Столкнулся с проблемой. У меня таблица из 7 колонок и 235000 строк. Макрос не разбивает на страницы. Вернее он страницы создает но они внутри пустые. Тестировал с меньшим количеством строк примерно 1000. Макрос срабатывал. Подскажите метод решения.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations