1

I would like to do something similar as this thread, but got #REF! error. I want to convert it into customised rows * columns, e.g. convert the 3 * 4 table into 6 * 2 format. How to achieve this?

enter image description here

8
  • The issue why this approach is not working for you is that this approach requires that all numbers are in one column. Technically, you could achieve something like this using different approaches. It would be useful to understand how you want to distribute the numbers across the two columns. Do you want to have in column F, for example, 1, 5, 9, 2, 6 or 1-6?
    – karl
    Jul 10, 2022 at 20:36
  • I would like 1-6, thanks
    – lanselibai
    Jul 11, 2022 at 6:01
  • 1
    Change the A1:D3 to A1:A12, you should covert the range to one column.
    – Lee
    Jul 11, 2022 at 6:51
  • My raw data is already in a table format. Is there a direct way to convert any size of table into customised rows * columns?
    – lanselibai
    Jul 11, 2022 at 10:12
  • Thank you, could you please also help me, how to make it 1,2,3,4,5,6 in the first column, and 7,8,9,10,11,12 in the second column?
    – lanselibai
    Jul 13, 2022 at 22:36

1 Answer 1

1

The following approach uses the very flexible Let function, which, however, is only available in Excel 365 and Excel 2021:

=LET(Matrix,$A$1:$D$3,rowsMatrix,ROWS(Matrix),colsMatrix,COLUMNS(Matrix),
cellValues,SEQUENCE((rowsMatrix*colsMatrix)/2,2,0),
INDEX(Matrix,INT(cellValues/colsMatrix)+1,MOD(cellValues,colsMatrix)+1))

EDIT: Additional Question in the Comments

In the approach described above, the matrix is distributed row-by-row among the columns, i.e., the first row starts with 1, 2, and so on.

To distribute the matrix by columns, i.e., column 1 has values 1-6 and column 2 has values 7-12, the SEQUENCE statement must be adjusted accordingly. In particular, the SEQUENCE statement controls the distribution mechanism, and you want to get a SEQUENCE that moves vertically rather than horizontally. Therefore, simply replace the SEQUENCE statement in the LET function with the following:

TRANSPOSE(SEQUENCE(2,(rowsMatrix*colsMatrix)/2,0))

If you want to understand to what extent the two SEQUENCES differ, simply enter the following formulas in Excel:

=SEQUENCE((3*4)/2,2,0)
=TRANSPOSE(SEQUENCE(2,(3*4)/2,0))

Another tangible approach would be to transform the data into a single column via (where, e.g., $F$1 is the top cell of the target range):

Option 1:

=OFFSET($A$1,INT((ROW()-ROW($F$1))/COLUMNS($A$1:$D$1)),
MOD(ROW()-ROW($F$1),COLUMNS($A$1:$D$1)))

Option 2:

=INDEX($A$1:$D$3,INT((ROW()-ROW($F$1))/COLUMNS($A$1:$D$1))+1,
MOD(ROW()-ROW($F$1),COLUMNS($A$1:$D$1))+1)

Thus, both options 1 and 2 are simply helper columns to which you can then apply the function below. Since the function also works if you enter the entire column, this approach seems quite flexible as well:

=INDEX($F:$F,SEQUENCE(6,2))
1
  • 1
    A future release excel formula release could see TOCOL() and WRAPCOLS() formulas which would do this transformation.
    – gns100
    Jul 11, 2022 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .