excelvbaexcel-formulapowerquerym

Stack Integer Sequences from a List


Intro

The Task

Size Result
2 1
5 2
3 1
2
3
4
5
1
2
3

Solution

  • So, here is one way using Excel Formula:

    =LET(_a, A2#, _b, SEQUENCE(, MAX(_a)), TOCOL(IF(_b <= _a, _b, 0/0), 2))
    


    Also, in place of IF() --> IFS() can be used:

    =LET(_a, A2#, _b, SEQUENCE(, MAX(_a)), TOCOL(IFS(_b <= _a, _b), 2))
    
    

    Since we are dealing with numbers, we use in the following manner as well:

    =LET(_a, A2#, _b, SEQUENCE(, MAX(_a)), TOCOL(_b/(_b <= _a), 2))