Skip i'r prif gynnwys

Sut i rannu rhestr hir yn grwpiau cyfartal yn Excel?

rhestr rhaniad doc i grwpiau 4

Os oes gennych chi restr hir o ddata yr oedd angen ei rannu'n grwpiau cyfartal lluosog fel y dangosir y llun isod, sut allech chi ddelio â'r dasg hon yn gyflym ac yn hawdd yn Excel?

Rhannwch restr hir yn grwpiau cyfartal lluosog gyda chod VBA

Rhannwch restr hir yn grwpiau cyfartal lluosog gyda Kutools ar gyfer Excel


Ac eithrio copïo a gludo'r data fesul un, gall y cod VBA canlynol ffafrio chi hefyd, gwnewch y camau canlynol:

1. Daliwch i lawr y ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Rhannwch restr hir yn grwpiau cyfartal lluosog

Sub SplitIntoCellsPerColumn()
'updateby Extendoffice
    Dim xRg As Range
    Dim xOutRg As Range
    Dim xCell As Range
    Dim xTxt As String
    Dim xOutArr As Variant
    Dim I As Long, K As Long
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
Sel:
    Set xRg = Nothing
    Set xRg = Application.InputBox("please select data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Areas.Count > 1 Then
        MsgBox "does not support multiple selections, please select again", vbInformation, "Kutools for Excel"
        GoTo Sel
    End If
    If xRg.Columns.Count > 1 Then
        MsgBox "does not support multiple columns,please select again", vbInformation, "Kutools for Excel"
        GoTo Sel
    End If
    Set xOutRg = Application.InputBox("please select a cell to put the result:", "Kutools for Excel", , , , , , 8)
    If xOutRg Is Nothing Then Exit Sub
    I = Application.InputBox("the number of cell per column:", "Kutools for Excel", , , , , , 1)
    If I < 1 Then
        MsgBox "incorrect enter", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    ReDim xOutArr(1 To I, 1 To Int(xRg.Rows.Count / I) + 1)
    For K = 0 To xRg.Rows.Count - 1
      xOutArr(1 + (K Mod I), 1 + Int(K / I)) = xRg.Cells(K + 1)
    Next
    xOutRg.Range("A1").Resize(I, UBound(xOutArr, 2)) = xOutArr
End Sub

3. Yna, pwyswch F5 allwedd i redeg y cod hwn, ac yn y blwch popped out, dewiswch y golofn rydych chi am ei rhannu'n grwpiau lluosog, gweler y screenshot:

rhestr rhaniad doc i grwpiau 1

4. a chliciwch OK botwm, yna dewiswch gell lle rydych chi am ddod o hyd i'r canlyniad yn y blwch prydlon canlynol, gweler y screenshot:

rhestr rhaniad doc i grwpiau 2

5. Cliciwch OK, a nodwch nifer y celloedd rydych chi am eu rhannu fesul colofn yn y blwch prydlon, gweler y screenshot:

rhestr rhaniad doc i grwpiau 3

6. Yn olaf, cliciwch OK i orffen y cod, ac mae'r data rhestr a ddewiswyd wedi'i rannu'n grwpiau cyfartal lluosog yn ôl yr angen, gweler y screenshot:

rhestr rhaniad doc i grwpiau 4


Os ydych chi wedi gosod Kutools ar gyfer Excel, Gyda'i Trawsnewid Ystod nodwedd, gallwch chi rannu rhestr hir yn gyflym yn sawl colofn a rhes, ar ben hynny, gallwch chi hefyd gyfuno colofnau lluosog yn un rhestr hir.

Kutools ar gyfer Excel : gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 30 diwrnod. 

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel a ganlyn:

1. Dewiswch y rhestr hir rydych chi am ei rhannu, ac yna cliciwch Kutools > Ystod > Trawsnewid Ystod, gweler y screenshot:

2. Yn y Trawsnewid Ystod blwch deialog, dewiswch Colofn sengl i amrediad O dan y Trawsnewid math adran, ac yna gwirio Gwerth sefydlog a nodwch nifer y celloedd fesul rhes yn y blwch, gweler y screenshot:

rhestr rhaniad doc i grwpiau 7

3. Yna cliciwch Ok, a dewis cell lle rydych chi am ddod o hyd i'r canlyniad yn y blwch prydlon, gweler y screenshot:

rhestr rhaniad doc i grwpiau 8

4. A chliciwch OK botwm, mae'r data yn y rhestr wedi'i rannu'n grwpiau cyfartal lluosog yn ôl yr angen.

Dadlwythwch a threial am ddim Kutools ar gyfer Excel Nawr !


Kutools ar gyfer Excel: gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 30 diwrnod. Dadlwythwch a threial am ddim Nawr!

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
the code works great for me. How do I change it from asking how many in each colum to how many columns needed? so that it equally divides the information into a set number of columns.
This comment was minimized by the moderator on the site
Hello, trinetta,
May be the following article can help you, in that article, there are some formulas may meet your need. Please check it:
https://www.extendoffice.com/documents/excel/681-excel-change-columns-to-rows.html
This comment was minimized by the moderator on the site
The link only tells me how to do the same thing. It doesnt tell me how to tell the code or formula how many columns i need...just how many in each column.
This comment was minimized by the moderator on the site
Hi, Tpdixon,
In that article, the formula: =OFFSET($A$1,COLUMNS($A1:A1)-1+(ROWS($1:1)-1)*5 can help you to split the list into mulitiple columns, you just need to change the number 5 to other number you need, it represents the column number.
After entering this formula, you should drag the fill handle acrross to right with 5 cells.
Please try, thank you!
This comment was minimized by the moderator on the site
how can I change it from the number of cells per column to the number of columns needed. so that the data is split up evenly amongst a number of columns instead of picking how many to have in each column?
This comment was minimized by the moderator on the site
I copied the code and Excel 365 says syntax error.
This comment was minimized by the moderator on the site
This comes in very handy! One question: In the VBA code how can I transpose the output? So instead of xRg.Rows.Count / I = number of colums output, the output is generated as xRg.Rows.Count / I = number of rows output with I being the number of columns per row.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations