Advertisement
RemcoE33

Transpose n number of rows

Jul 16th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Returns transposed array split over n rows.
  3. *
  4. * @param {A1:A21} array - Input (single column) range.
  5. * @param {7} skipping - Enter desired n rows for splitting.
  6. * @return {array} transposed dataset split by skipping.
  7. * @customfunction
  8. */
  9. function N_TRANSPOSE(array, skipping){
  10.   const data = array.flat()
  11.   const res = [];
  12.     for (let i = 0; i < data.length; i += skipping) {
  13.         const chunk = data.slice(i, i + skipping);
  14.         res.push(chunk);
  15.     }
  16.   return res;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement