Skip to content

Instantly share code, notes, and snippets.

@Softwaretrain
Created May 15, 2023 07:59
Show Gist options
  • Save Softwaretrain/f5a005b4d907b910217617f35572d17e to your computer and use it in GitHub Desktop.
Save Softwaretrain/f5a005b4d907b910217617f35572d17e to your computer and use it in GitHub Desktop.
//SplitAmount
=ArrayFormula(LET(
z,division,
count,ROUNDUP(amount/z,),
a,SCAN(0,count,LAMBDA(x,y,x+y))-count+1,
b,SEQUENCE(SUM(count)),
c,SCAN(0,b,LAMBDA(g,h,XLOOKUP(h,a,array,g))),
e,BYROW(amount,LAMBDA(x,LET(n,z,a,MOD(x,n),b,REPT(n&"-",x/n)&IF(a,a,""),b))),
f,TEXTJOIN(",",,e),
g,TOCOL( ArrayFormula(split(transpose(SPLIT(f,",")),"-")),1),
h,HSTACK(c,g),h))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment