Skip to main content

Conas tábla mór a roinnt ina iliomad táblaí beaga in Excel?

Má tá bileog oibre mór agat ina bhfuil ilcholúin agus sonraí na céadta nó na mílte sraitheanna, anois, ba mhaith leat an tábla mór seo a roinnt ina iliomad táblaí beaga bunaithe ar luach an cholúin nó líon na sraitheanna chun na torthaí seo a leanas a fháil. Conas a d’fhéadfá déileáil leis an tasc seo in Excel?

Príomh Tábla   Roinn an tábla i dtáblaí iolracha de réir luach an cholúin Roinn an tábla i dtáblaí iolracha de réir chomhaireamh na sraitheanna

Roinn tábla mór i dtáblaí iolracha bunaithe ar luach an cholúin le cód VBA

Roinn tábla mór i dtáblaí iolracha bunaithe ar líon sonrach na sraitheanna le cód VBA

Roinn tábla mór i dtáblaí iolracha bunaithe ar luach colún nó líon na sraitheanna le gné iontach


Roinn tábla mór i dtáblaí iolracha bunaithe ar luach an cholúin le cód VBA

Chun an tábla mór seo a roinnt ina tháblaí iolracha bunaithe ar luach colún ar leith, is féidir leis an gcód VBA seo a leanas fabhar a thabhairt duit. Déan mar seo le do thoil:

1. Coinnigh síos an ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Roinn tábla mór i dtáblaí iolracha de réir eochaircholún:

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. Tar éis an cód a ghreamú, brúigh F5 eochair chun an cód seo a rith, agus bosca pras popped amach, roghnaigh an tsraith ceanntásc ó do chuid sonraí, féach an scáileán:

4. Ansin, cliceáil OK, agus bosca dialóige eile popped amach, roghnaigh na sonraí colún ar mhaith leat an tábla a roinnt bunaithe orthu, féach an scáileán:

5. Cliceáil OK, roinneadh an tábla mór seo ina iliomad bileoga oibre de réir luach an cholúin atá suite i ndiaidh an mháistirbhileog. Agus ainmnítear na bileoga oibre nua le luach an cholúin. Féach an pictiúr:


Roinn tábla mór i dtáblaí iolracha bunaithe ar líon sonrach na sraitheanna le cód VBA

Más gá duit an tábla a roinnt ina tháblaí iolracha bunaithe ar líon na sraitheanna, is féidir leis an gcód VBA seo a leanas cabhrú leat.

1. Coinnigh síos an ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Roinn tábla mór i dtáblaí iolracha de réir líon na sraitheanna:

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. Ansin, brúigh F5 eochair, sa bhosca dialóige popped up, roghnaigh an tsraith ceanntásc, féach an scáileán:

4. Ansin, cliceáil OK, agus sa dara bosca pras, roghnaigh an raon sonraí a theastaíonn uait a roinnt de réir sraitheanna a chomhaireamh, féach an scáileán:

5. Agus ansin, téigh ar cliceáil OK cnaipe, sa tríú bosca pras, iontráil líon na sraitheanna ar mhaith leat a roinnt leo, féach an scáileán:

6. Ansin, cliceáil OK cnaipe, tá an máistir-tábla roinnte ina iliomad bileoga oibre bunaithe ar líon na sraitheanna mar atá thíos ar an scáileán:


Roinn tábla mór i dtáblaí iolracha bunaithe ar luach colún nó líon na sraitheanna le gné iontach

B’fhéidir go bhfuil na cóid thuas deacair d’fhormhór na n-úsáideoirí, anseo, tabharfaidh mé gné iontach isteach-Scoilt Sonraí of Kutools le haghaidh Excel. Leis an bhfóntas seo, is féidir leat tábla mór a roinnt ina iliomad táblaí de réir eochaircholúin nó líon na sraitheanna go tapa agus go héasca.

Leid:Chun é seo a chur i bhfeidhm Scoilt Sonraí gné, ar dtús, ba cheart duit an Kutools le haghaidh Excel, agus ansin an ghné a chur i bhfeidhm go tapa agus go héasca.

Tar éis a shuiteáil Kutools le haghaidh Excel, déan mar seo le do thoil:

1. Roghnaigh an raon sonraí a theastaíonn uait a roinnt, agus ansin, cliceáil Kutools Plus > Scoilt Sonraí, féach ar an scáileán:

2. Sa an Roinn Sonraí i mBileoga Oibre Il bosca dialóige, sonraigh na socruithe de réir do riachtanas:

(1.) Roghnaigh Colún sonrach or Sraitheanna seasta ó na Scoilt bunaithe ar alt de réir mar is gá duit;

(2.) Sonraigh ainm na mbileog oibre nua ón Rialacha liosta anuas, is féidir leat an Réimse or Iarmhír le hainmneacha na mbileog freisin.

3. Ansin, cliceáil Ok cnaipe, agus anois, tá an tábla mór roinnte ina iliomad táblaí beaga i leabhar oibre nua. Féach screenshots:

Roinn an tábla i dtáblaí iolracha de réir luach an cholúin Roinn an tábla i dtáblaí iolracha de réir chomhaireamh na sraitheanna

Cliceáil chun Íoslódáil Kutools le haghaidh Excel agus triail saor in aisce Anois!


Earraí níos coibhneasta:

  • Roinn Leabhar Oibre chun Comhaid Excel a Dheighilt in Excel
  • B’fhéidir go mbeidh ort leabhar oibre mór a roinnt chun comhaid Excel a scaradh le gach bileog oibre den leabhar oibre a shábháil mar chomhad Excel aonair. Mar shampla, is féidir leat leabhar oibre a roinnt ina iliomad comhad Excel aonair agus ansin gach comhad a sheachadadh chuig duine difriúil chun é a láimhseáil. Trí sin a dhéanamh, féadfaidh tú a chur ar dhaoine áirithe sonraí faoi leith a láimhseáil, agus do chuid sonraí a choinneáil slán. Tabharfaidh an t-alt seo bealaí isteach chun leabhar mór oibre a roinnt chun comhaid Excel a scaradh bunaithe ar gach bileog oibre.
  • Roinn Ainm Iomlán ar an gcéad ainm agus an t-ainm deireanach in Excel
  • Má cheaptar go bhfuil uainchlár ainm agat mar a thaispeánann an chéad ghrianghraf scáileáin i gcolún aonair thíos, agus ní mór duit an t-ainm iomlán a roinnt ar an gcolún céadainm column colún lár-ainm agus ar an gcolún ainm deiridh mar a thaispeántar an pictiúr seo a leanas. Seo roinnt modhanna fánacha chun cabhrú leat an fhadhb seo a réiteach.
  • Scoilt Colún Fada Isteach Colúin Iolracha in Excel
  • Má tá sonraí fada colúin agat in Excel a bheidh trioblóideach agus tú ag breathnú orthu. Ach anois más féidir leat an liosta fada sin a roinnt ina iliomad colúin in Excel, déanfaidh sé an t-amharc go caothúil.

 


  • Barra Foirmle Super (cuir línte iolracha téacs agus foirmle in eagar go héasca); Leagan Amach Léitheoireachta (líon mór cealla a léamh agus a chur in eagar go héasca); Greamaigh go dtí an Raon Scagtha...
  • Cumaisc Cealla / Sraitheanna / Colúin agus Sonraí a Choinneáil; Ábhar Cealla Scoilt; Comhcheangail Sraitheanna Dúblacha agus Suim / Meán... Cill Dúblach a Chosc; Déan comparáid idir Ranganna...
  • Roghnaigh Dúblach nó Uathúil Sraitheanna; Roghnaigh Blank Rows (tá na cealla uile folamh); Aimsigh Super agus Fuzzy Aimsigh i go leor Leabhar Oibre; Roghnaigh go randamach ...
  • Cóip Díreach Cealla Il gan tagairt fhoirmle a athrú; Tagairtí Cruthaigh Auto chuig Bileoga Il; Cuir Urchair isteach, Boscaí Seiceála agus go leor eile ...
  • Foirmlí is Fearr agus Cuir isteach go tapa, Ranganna, Cairteacha agus Pictiúir; Cealla a Chriptiú le pasfhocal; Cruthaigh Liosta Ríomhphoist agus seol ríomhphoist ...
  • Sliocht Téacs, Cuir Téacs leis, Bain de réir Poist, Bain Spás; Subtotals Paging a chruthú agus a phriontáil; Tiontaigh Idir Ábhar Cealla agus Tráchtanna...
  • Scagaire Super (scéimeanna scagaire a shábháil agus a chur i bhfeidhm ar bhileoga eile); Ard-Sórtáil de réir míosa / seachtaine / lae, minicíocht agus níos mó; Scagaire Speisialta le cló trom, iodálach ...
  • Comhcheangail Leabhair Oibre agus Bileoga Oibre; Cumaisc Táblaí bunaithe ar eochaircholúin; Roinn Sonraí i Ilbhileoga; Baisc Tiontaigh xls, xlsx agus PDF...
  • Grúpáil Tábla Pivot de réir uimhir na seachtaine, lá na seachtaine agus níos mó ... Taispeáin Cealla Díghlasáilte, Faoi Ghlas de réir dathanna éagsúla; Aibhsigh Cealla a bhfuil Foirmle / Ainm orthu...
cluaisín kte 201905
  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
bun 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