Skip to content

Instantly share code, notes, and snippets.

@jimpea
Last active May 4, 2024 08:15
Show Gist options
  • Save jimpea/e3ef74752d41a58df12ffe6fce718167 to your computer and use it in GitHub Desktop.
Save jimpea/e3ef74752d41a58df12ffe6fce718167 to your computer and use it in GitHub Desktop.
Excel Lambda function to convert an array to a list
FLATTEN = LAMBDA(array,
LET(
//name definitions
rows_, ROWS(array),
cols_, COLUMNS(array),
// index the zero-based array
seq_, SEQUENCE(rows_*cols_, 1, 0, 1),
// row and column indices
row_, INT(seq_/cols_),
col_, MOD(seq_, cols_),
// return
// get array cell by row and column index
INDEX(array, row_ + 1, col_ + 1)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment