INSERTBLANKAT

=INSERTATROW(data, atRow)

data
Required. Data range
atRow
The row number that blank cell should be inserted.

INSERTBLANKAT function inserts blank cells at every X row in a given range.
Joined
Feb 28, 2002
Messages
2,546
INSERTBLANKAT function inserts blank cells at every X row in a given range.

The mini-sheet - G:O columns - shows the steps to build the final Lambda formula.

Excel Formula:
=LAMBDA(data,atRow,
    LET(rows, ROWS(data),
        cols, COLUMNS(data),
        rowsWithBlanks, SEQUENCE(rows+rows/(atRow-1)),
        blankRow,MOD(rowsWithBlanks,atRow),
        rowIndex, rowsWithBlanks-INT(rowsWithBlanks/atRow),
        IF(blankRow,INDEX(data,rowIndex, SEQUENCE(,cols)),"")
))
INSERTATBLANK.xlsx
ABCDEFGHIJKLMNOPQRS
1Field1Field2Field3At RowRowsColsRows with Blanks0 is blank rowRow IndexResultLambda function
2January651653123111January65165January65165
3February66166222February66166February66166
4March67167302
5April68168413March67167March67167
6May69169524April68168April68168
7June70170604
8July72172715May69169May69169
9August73173826June70170June70170
10September69169906
11October701701017July72172July72172
12November721721128August73173August73173
13December731731208
141319September69169September69169
1514210October70170October70170
1615010
1716111November72172November72172
1817212December73173December73173
1918012
20
INSERTBLANKAT
Cell Formulas
RangeFormula
G2G2=ROWS(A2:C13)
H2H2=COLUMNS(A2:C13)
I2:I19I2=SEQUENCE(G2+G2/(E2-1))
J2:J19J2=MOD(I2#,E2)
K2:K19K2=I2#-INT(I2#/E2)
M2:O19M2= IF(J2#,INDEX(A2:C13,K2#, SEQUENCE(,H2)),"")
Q2:S19Q2=LAMBDA(data,atRow, LET(rows, ROWS(data), cols, COLUMNS(data), rowsWithBlanks, SEQUENCE(rows+rows/(atRow-1)), blankRow,MOD(rowsWithBlanks,atRow), rowIndex, rowsWithBlanks-INT(rowsWithBlanks/atRow), IF(blankRow,INDEX(data,rowIndex, SEQUENCE(,cols)),"") ))(A2:C13,E2)
Dynamic array formulas.
 
Upvote 0
Hi Suat, great function. I like how you've built the pattern equations. Then I thought, what if we include another argument, the gap size.
And since you did it already with math expressions I chose an alternative solution, using only arrays "geometry".
Here is the concept, step by step.
Book2
ABCDEFGHIJKLMNOPQR
1Creating rows index pattern.
21. grouping x-13 flatten exp. array4. exclude extra rows
3rows (r)q=seq(r)w=wraprows(q,x-1)t=tocol(e)k=take(t,xmatch(r,t))
420=SEQUENCE(A4)=WRAPROWS(C5#,A7-1)=TOCOL(E16#)=TAKE(K5#,XMATCH(A4,K5#))
5112311
6at row (x)2456225. final
74378933 =iferr(INDEX(a,k,seq(clms(a))),"")
84101112#N/A#N/A
9gap (y)5131415#N/A#N/A
102616171844
1171920#N/A55
12866
1392. expanding y gap#N/A#N/A
1410e=expand(w,,x-1+y)#N/A#N/A
1511=EXPAND(E5#,,A7-1+A10)77
1612123#N/A#N/A88
1713456#N/A#N/A99
1814789#N/A#N/A#N/A#N/A
1915101112#N/A#N/A#N/A#N/A
2016131415#N/A#N/A1010
2117161718#N/A#N/A1111
22181920#N/A#N/A#N/A1212
2319#N/A#N/A
2420#N/A#N/A
251313
261414
271515
28#N/A#N/A
29#N/A#N/A
301616
311717
321818
33#N/A#N/A
34#N/A#N/A
351919
362020
37#N/A
38#N/A
39#N/A
40
Sheet1
Cell Formulas
RangeFormula
C4,E4,E15,K4,M4C4=FORMULATEXT(C5)
C5:C24C5=SEQUENCE(A4)
E5:G11E5=WRAPROWS(C5#,A7-1)
K5:K39K5=TOCOL(E16#)
M5:M36M5=TAKE(K5#,XMATCH(A4,K5#))
E16:I22E16=EXPAND(E5#,,A7-1+A10)
Dynamic array formulas.
 
The function:
INSRWS(a,x,[g]) INSert RoWS
a: array
x: at row x , integer >1
[g]: gap size, integer >0 , if omitted g=1
Excel Formula:
=LAMBDA(a, x, [g],
    LET(
        y, IF(g, g, 1),
        r, ROWS(a),
        t, TOCOL(EXPAND(WRAPROWS(SEQUENCE(r), x - 1), , x - 1 + y)),
        IFERROR(INDEX(a, TAKE(t, XMATCH(r, t)), SEQUENCE(, COLUMNS(a))), "")
    )
)
Book2
ABCDEFGHIJKLMNOPQ
1x,3,g,omittedx,4,g,omittedx,5,g,2
2a=INSRWS(B3:D14,3)=INSRWS(B3:D14,4)=INSRWS(B3:D14,5,2)
3January65165January65165January65165January65165
4February66166February66166February66166February66166
5March67167March67167March67167
6April68168March67167April68168
7May69169April68168April68168
8June70170May69169
9July72172May69169June70170May69169
10August73173June70170June70170
11September69169July72172July72172
12October70170July72172August73173August73173
13November72172August73173September69169
14December73173
15September69169October70170September69169
16October70170November72172October70170
17December73173November72172
18November72172December73173
19December73173
20
21x,6,g,2x,6,g,3x,7,g,3
22=INSRWS(B3:D14,6,2)=INSRWS(B3:D14,6,3)=INSRWS(B3:D14,7,3)
23January65165January65165January65165
24February66166February66166February66166
25March67167March67167March67167
26April68168April68168April68168
27May69169May69169May69169
28June70170
29
30June70170
31July72172June70170
32August73173July72172July72172
33September69169August73173August73173
34October70170September69169September69169
35October70170October70170
36November72172
37November72172December73173
38December73173
39November72172
40December73173
41
Sheet2
Cell Formulas
RangeFormula
F2,N22,J22,F22,N2,J2F2=FORMULATEXT(F3)
F3:H19F3=INSRWS(B3:D14,3)
J3:L17J3=INSRWS(B3:D14,4)
N3:P18N3=INSRWS(B3:D14,5,2)
F23:H38F23=INSRWS(B3:D14,6,2)
J23:L40J23=INSRWS(B3:D14,6,3)
N23:P37N23=INSRWS(B3:D14,7,3)
Dynamic array formulas.
 
A minor note: Just noticed that your function leaves a blank last row. I thought that was a design choice, but for other values of "atRow" it doesn't happen.
Book2
ABCDEFGHIJKLMNO
1atRow,3x,3
2a=INSERTBLANKAT(B3:D14,3)=INSRWS(B3:D14,3)check rows
3January65165January65165January65165=ROWS(F3#)
4February66166February66166February6616618
5March67167
6April68168March67167March67167=ROWS(J3#)
7May69169April68168April6816817
8June70170
9July72172May69169May69169
10August73173June70170June70170
11September69169
12October70170July72172July72172
13November72172August73173August73173
14December73173
15September69169September69169
16October70170October70170
17
18November72172November72172
19December73173December73173
20
21
22atRow,6x,6
23=INSERTBLANKAT(B3:D14,6)=INSRWS(B3:D14,6)check rows
24January65165January65165=ROWS(F24#)
25February66166February6616614
26March67167March67167
27April68168April68168=ROWS(J24#)
28May69169May6916914
29
30June70170June70170
31July72172July72172
32August73173August73173
33September69169September69169
34October70170October70170
35
36November72172November72172
37December73173December73173
38
Sheet3
Cell Formulas
RangeFormula
F2,N27,N24,J23,F23,N6,N3,J2F2=FORMULATEXT(F3)
F3:H20F3=INSERTBLANKAT(B3:D14,3)
J3:L19J3=INSRWS(B3:D14,3)
N4,N25N4=ROWS(F3#)
N7,N28N7=ROWS(J3#)
F24:H37F24=INSERTBLANKAT(B3:D14,6)
J24:L37J24=INSRWS(B3:D14,6)
Dynamic array formulas.
 
@Xlambda: I like how you used WRAPROWS and EXPAND in INSRWS. The "gap size" idea is great. Thanks for the improvement!

What I like more, seeing alternative formulas created and posted with different functions for the Lambda functions I am building. I am learning a lot. Otherwise, it is impossible to know that there is other useful functions/logic that exist to be used to do the same thing.
Another thing is, I also like creating the functions with steps by extracting each step in separate ranges and then imploding them as the actual function at the end. I understand the used functions much easier that way. Again, F9 doesn't work in LET or Lambda, anything that is calculated as a name returns #NAME? error (I understand F9 has a scope and can't see other than the selected section in a formula) and it really makes it harder to read it on the function directly.

The blank last row - if the last group had enough items, 5, then it would have also put a blank row for that too. Since there are only November and December left after the group of fives, no blank is added to the end. But I like how INSRWS works and doesn't add an extra blank at the end where it is necessary according to the logic in the initial formula. On second thought, the last blank is not that useful.
 

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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