INSERTBLANKS

=INSERTBLANKS(range,integer)

array
a range of cells to insert blanks into
space_count
how many blank rows to insert between values

INSERTBLANKS will insert blank rows between the values of a given range

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,963
Office Version
  1. 365
Platform
  1. Windows
INSERTBLANKS will insert blank rows between the values of a given range.

Excel Formula:
=LAMBDA(
    array,space_count,
    LET(
        acnt,ROWS(array),
        total,acnt+((acnt-1)*space_count),
        s,(SEQUENCE(total)-1)/(space_count+1)+1,
            MAKEARRAY(
                total,
                COLUMNS(array),
                LAMBDA(
                    r,c,
                    IF(ISINT(INDEX(s,r)),
                        INDEX(array,INDEX(s,r),c),
                        ""
                    )
                )
            )
    )
)

LAMBDA
ABCDEFGHIJKLMNO
11111AEIAEI
222BFJ
333CGK
442DHLBFJ
55
6
732CGK
8
9
104DHL
11
12
1353
Sheet1
Cell Formulas
RangeFormula
A1:A5A1=SEQUENCE(5)
C1:C13C1=INSERTBLANKS(A1#,2)
E1:E3E1=SEQUENCE(3)
G1:G13G1=INSERTBLANKS(E1#,5)
M1:O10M1=INSERTBLANKS(I1:K4,2)
Dynamic array formulas.
 
Upvote 0
what isint?
Other than people that can't find the apostrophe key, ISINT is referenced as VBA code, but not even as a function as far as I could find. However, replacing it with ISNUMBER seems to work.
 
Sorry about that. I forgot to include it. It's another lambda function.

Excel Formula:
=LAMBDA(range,MAP(range,LAMBDA(x,x-INT(x)=0)))
 
I just need the insert blank at the change in values in one column only (by column index number). But, might be another ten nested functions to get there.
 
Hi, non-iterative alternative of same task. (I am on a kind of campaign to increase the level of awareness that iterative algorithm designs (lambda helper functions) can be quite slow sometimes and should be used only if there is no other non-iterative solution. Hopefully, I will open soon a kind of manifest called Lambda Performance Act (LPA) and I'd like anybody to contribute with ideas for the lambda community, especially you, if is possible 😉)
INSRWS(a,n) a,array ; n, nr. rows to insert, does not call any other function

Excel Formula:
=LAMBDA(a, n, DROP(IFNA(INDEX(a, TOCOL(EXPAND(+SEQUENCE(ROWS(a)), , n + 1)), SEQUENCE(, COLUMNS(a))), ""), -n))
Book1
ABCDEFGHIJKLM
1
2acalc time: 1min 36seccalc time: instant
3=SEQUENCE(10000,3)=INSERTBLANKS(B4#,1)=INSRWS(B4#,1)
4123123123
5456
6789456456
7101112
8131415789789
9161718
10192021101112101112
11222324
12252627131415131415
13282930
14313233161718161718
15343536
16373839192021192021
17404142
18434445222324222324
19464748
20495051252627252627
21525354
22555657282930282930
23585960
24616263313233313233
25646566
26676869343536343536
27707172
28737475373839373839
29767778
30798081404142404142
31828384
32858687434445434445
33888990
34919293464748464748
35949596
36979899495051495051
37100101102
38103104105525354525354
39106107108
Sheet1
Cell Formulas
RangeFormula
B3,F3,J3B3=FORMULATEXT(B4)
B4:D10003B4=SEQUENCE(10000,3)
F4:H20002F4=INSERTBLANKS(B4#,1)
J4:L20002J4=INSRWS(B4#,1)
Dynamic array formulas.
 
Hi, non-iterative alternative of same task. (I am on a kind of campaign to increase the level of awareness that iterative algorithm designs (lambda helper functions) can be quite slow sometimes and should be used only if there is no other non-iterative solution. Hopefully, I will open soon a kind of manifest called Lambda Performance Act (LPA) and I'd like anybody to contribute with ideas for the lambda community, especially you, if is possible 😉)
INSRWS(a,n) a,array ; n, nr. rows to insert, does not call any other function

Excel Formula:
=LAMBDA(a, n, DROP(IFNA(INDEX(a, TOCOL(EXPAND(+SEQUENCE(ROWS(a)), , n + 1)), SEQUENCE(, COLUMNS(a))), ""), -n))
Book1
ABCDEFGHIJKLM
1
2acalc time: 1min 36seccalc time: instant
3=SEQUENCE(10000,3)=INSERTBLANKS(B4#,1)=INSRWS(B4#,1)
4123123123
5456
6789456456
7101112
8131415789789
9161718
10192021101112101112
11222324
12252627131415131415
13282930
14313233161718161718
15343536
16373839192021192021
17404142
18434445222324222324
19464748
20495051252627252627
21525354
22555657282930282930
23585960
24616263313233313233
25646566
26676869343536343536
27707172
28737475373839373839
29767778
30798081404142404142
31828384
32858687434445434445
33888990
34919293464748464748
35949596
36979899495051495051
37100101102
38103104105525354525354
39106107108
Sheet1
Cell Formulas
RangeFormula
B3,F3,J3B3=FORMULATEXT(B4)
B4:D10003B4=SEQUENCE(10000,3)
F4:H20002F4=INSERTBLANKS(B4#,1)
J4:L20002J4=INSRWS(B4#,1)
Dynamic array formulas.

That's crazy! Is it because MAKEARRAY is slow, or is it really because it's referencing a helper LAMBDA?
 
MAKEARRAY and all others, are triggering one 1D or 2D iterative algorithms ex: 2 nested loops, for every row, every column,...apply function...next row, next column.
To understand it better, using an explicit example:
Always MAKEARRAY(120,30,LAMBDA(r,c,r+c)) will be slower than =SEQUENCE(120)+SEQUENCE(,30)
It's an iterative calculation versus "in bulk" dynamic calculation. memory is allocated diffrently.
Hope that helps. 😉✌️
 
**
 
Last edited:

Forum statistics

Threads
1,224,829
Messages
6,181,224
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top