In Excel, Combine Every N Row into A New Row

esProc DesktopesProc Desktop
3 min read

Problem description & analysis:

In column F, every four rows correspond to one record:

ABCDEF
1NameAddressCityShort IDCompany 1
22222 al street
3Blue cheese
41
5Company 2
61111 arm rd
7Ranch
82
9Company 3
103333 raindrop drive
11Peanut
123

We need to re-arrange column F to make a standard table by entering each record to cells A~D row by row:

ABCDEF
1NameAddressCityShort IDCompany 1
2Company 12222 al streetBlue cheese12222 al street
3Company 21111 arm rdRanch2Blue cheese
4Company 33333 raindrop drivePeanut31
5Company 2
61111 arm rd
7Ranch
82
9Company 3
103333 raindrop drive
11Peanut
123

Solution:

Use SPL XLL to enter the formula below:

=spl("=?.(~(1)).group((#-1)\4)",F1:F12)

As shown in the picture below:

r/esProc_Desktop - In Excel, Combine Every N Rows into A New Row

Explanation:

~(1) represents getting the first sub-member of the current member. The group()function performs a grouping operation by putting members having the same (#-1)\4 into the same group; # represents the ordinal number of a member, and symbol \ means a rounded division.

SPL XLL is now FREE to download and apply: http://www.scudata.com/download-Desktop

10
Subscribe to my newsletter

Read articles from esProc Desktop directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

esProc Desktop
esProc Desktop

esProc Desktop is a desktop data processing & analytics tool and is specifically designed for ordinary business people. It supports complex computations & spreadsheet data manipulation, can deal with tasks that are hard to accomplish in Excel, and in addition, generates more concise code than VBA and Python. esProc Desktop boasts all-around programming capabilities, supports multi-step interactive data analytics and is easy to use without configurations. This significantly lowers the technical threshold for data analytics.