Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to split a long list into equal groups in Excel?

doc split list to groups 4

If you have a long list of data needed to be split into multiple equal groups as following screenshot shown, how could you deal with this task quickly and easily in Excel?

Split a long list into multiple equal groups with VBA code

Split a long list into multiple equal groups with Kutools for Excel


Split one column or row into multiple equal groups:

With Kutools for Excel’s Transform Range feature, you can quickly convert a range of cells to a single row or column, you can also convert a single row or column to a range of cells.

doc split list to groups 9

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!



Excepting copy and paste the data one by one, the following VBA code also can do you a favor, please do with following steps:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Split a long list into multiple equal groups

Sub SplitIntoCellsPerColumn()
'updatebyExtendoffice 20160225
    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. Then press F5 key to run this code, and in the popped out box, please select the column that you want to split into multiple groups, see screenshot:

doc split list to groups 1

4. And click OK button, then select a cell where you want to locate the result in the following prompt box, see screenshot:

doc split list to groups 2

5. Click OK, and please enter the number of cells that you want to split per column in the prompt box, see screenshot:

doc split list to groups 3

6. Finally, click OK to finish the code, and the selected list data has been split into multiple equal groups as you need, see screenshot:

doc split list to groups 4


If you have installed Kutools for Excel, with its Transform Range feature, you can quickly split a long list into multiple columns and rows, moreover, you can also combine multiple columns into one long list.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as follows:

1. Select the long list that you want to split, and then click Kutools > Range > Transform Range, see screenshot:

doc split list to groups 6

2. In the Transform Range dialog box, select Single column to range under the Transform type section, and then check Fixed value and specify the number of cells per row in the box, see screenshot:

doc split list to groups 7

3. Then click Ok, and select a cell where you want to locate the result in the prompt box, see screenshot:

doc split list to groups 8

4. And click OK button, the data in the list has been split into multiple equal groups as you need.

Download and free trial Kutools for Excel Now !


Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    attom93 · 7 months ago
    I copied the code and Excel 365 says syntax error.
  • To post as a guest, your comment is unpublished.
    LM · 1 years ago
    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.