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!


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
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 · 1 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.