Can you automatically split single rows of data into multiple tables?

Viewed 22

I have many rows of data in Excel that is basically

name1 data1 data2 name2 data1 data2
value11 value12 value13 value14 value15 value16
value21 value22 value23 value24 value25 value26

Can I split it into many separate tables that change it to

name1 data1 data2
value11 value12 value13
value14 value15 value16

and another

name2 data1 data2
value21 value22 value23
value24 value25 value26

Basically, split a row of data into equal sized-table. Keep in mind, I have a lot of rows like these.

1 Answers

It depends on how many tables you want to create and if it can be done with a minimal manual intervention, for a really high number of tables, probably you will need the help of VBA. You can take benefit of the OFFSET function. You need to specify the offset value, width and hight. Here a sample for two tables as in your question:

sample excel file

In column A we define such parameters and the formula for getting a subset of the first spit is as follow:

=LET(count, 0, OFFSET($C$1,0,$A$3*count,$A$5,$A$7))

Then for the second split, copy the above formula to the cell you want to populate it and increment the count value by 1. Like this:

=LET(count, 1, OFFSET($C$1,0,$A$3*count,$A$5,$A$7))

and so on for the next spits. Using LET function, I consider it is easier to find where to replace the value in the formula.

If you want to make 10 spits it is feasible, for 100 splits then I would recommend you to build a process in VBA.

Another way (but it depends on your real situation) could be using HSTACK function having everything in a single formula. Use the following trick to generate generate an empty column as a separator:

IF(ROW(INDIRECT("A1:A"&($A$7+1))), "")

then to use it in the following formula:

=LET(count, 0, sep, IF(ROW(INDIRECT("A1:A"&($A$7+1))), ""), 
  HSTACK(OFFSET($C$1,0,$A$3*(count),$A$5,$A$7), 
  sep,OFFSET($C$1,0,$A$3*(count+1),$A$5,$A$7))
)

The above formula produces the same result as shown in the screenshot.

To add additional spits, just keep adding rows like the third one on the previous formula delimited by comma.

sep,OFFSET($C$1,0,$A$3*(count+2),$A$5,$A$7)),
sep,OFFSET($C$1,0,$A$3*(count+3),$A$5,$A$7)),
sep,OFFSET($C$1,0,$A$3*(count+3),$A$5,$A$7)),
...
...
sep,OFFSET($C$1,0,$A$3*(count+n),$A$5,$A$7))

something that can be implemented using and editor with regex feature for example. If you want to organize the new tables vertically you can use then: VSTACK in a similar way.

Related