How can I generate an array of numbers between multiple ranges defined in separate cells in Sheet?

前端 未结 2 1933
我在风中等你
我在风中等你 2021-01-25 05:16

A1: 1 | B1: 4
A2: 3 | B2: 6

How can I get {1, 2, 3, 3, 4, 4, 5, 6} out of this?<

2条回答
  •  醉梦人生
    2021-01-25 06:10

    Here is a relatively simple formula to generate the array you're talking about based on an infinite number of ranges in columns A and B.

    =ARRAYFORMULA(QUERY(SPLIT(FLATTEN(SEQUENCE(1,MAX(B1:B10-A1:A10)+1,0)+A1:A10&"|"&B1:B10),"|",0,0),"Select Col1 where Col1<=Col2 order by Col1",0))
    

    You can see it demonstrated in the tab called Demo 2 on this sheet.

提交回复
热议问题