Skip to content

Instantly share code, notes, and snippets.

@ncalm
Created July 24, 2026 22:59
Show Gist options
  • Select an option

  • Save ncalm/2465d3e2a5b3b18c46e88da87fe105cf to your computer and use it in GitHub Desktop.

Select an option

Save ncalm/2465d3e2a5b3b18c46e88da87fe105cf to your computer and use it in GitHub Desktop.
VSTACK.PAD and HSTACK.PAD Excel LAMBDA functions
PADSTACK = LAMBDA(function,
LAMBDA(item1,item2,position,
LET(
fn,IF(function=1,VSTACK,HSTACK),
e_rows,IF(function=1,ROWS(item2),position-1),
e_cols,IF(function=2,COLUMNS(item2),position-1),
IF(
AND(e_cols>0,e_rows>0),
LET(
e,MAKEARRAY(e_rows,e_cols,LAMBDA(r,c,NA())),
e_item2,IF(function=1,HSTACK,VSTACK)(e,item2),
fn(item1,e_item2)
),
fn(item1,item2)
)
)
)
);
VSTACK.PAD = PADSTACK(1);
HSTACK.PAD = PADSTACK(2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment