How to split a long list into equal groups in Excel?
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?
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() '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. 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:
4. And click OK button, then select a cell where you want to locate the result in the following prompt box, see screenshot:
5. Click OK, and please enter the number of cells that you want to split per column in the prompt box, see screenshot:
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:
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 30 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:
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:
3. Then click Ok, and select a cell where you want to locate the result in the prompt box, see screenshot:
4. And click OK button, the data in the list has been split into multiple equal groups as you need.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
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!