Transpose Rows/Cols of Table - single formula

ok… i looked at my code and realized it was twice as long and complicated as needed.
so i have reduced it to a more manageable minimal set of code.

here is the result (as before, its a ‘virtual’ transposed table - display-only)

and here is the shorter formula…

s1

How It Works line-by-line

  • the List() and WithName() collects the entire table into the 2d matrix M (a list of one-list-per-column)
  • for C=1 to NrColumns (Count(M) is the number of cols)
  • for R=1 to NrRows (Count(M.First()) is the number of rows)
  • show each cell M[C,R] padded and in fixed-width-font
  • next R and separate the cells with a space
  • next C and separate rows with a line-break
  • end the withname for M

This runs faster, has less moving parts, and is easier to follow.

Someone asked why the _Code()? it shows the cells in a fixed-width font. otherwise the width of each cell would be slightly different and they would not align properly.

Max

6 Likes