REPEAT

REPEAT(range, vertical_repeat, horizontal_repeat)
range
a range of cells (single or multiple column)
vertical_repeat
number of times to repeat the rows of the range
horizontal_repeat
number of times to repeat the columns of the range

REPEAT produces an array containing a number of copies of the input range stacked vertically and/or horizontally. The input range can be single or multiple column range.

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,927
Office Version
  1. 365
Platform
  1. Windows
REPEAT will duplicate an input range by a given multiple of rows and columns

Excel Formula:
=LAMBDA(
    range,vertical_repeats,horizontal_repeats,
    LET(
        r_cnt, ROWS(range),
        c_cnt, COLUMNS(range),
        ro,r_cnt*vertical_repeats,
        co,c_cnt*horizontal_repeats,
        rx,MOD(TRANSPOSE(SEQUENCE(co,ro,0)),r_cnt)+1,
        cx,MAKEARRAY(
            ro,co,
                LAMBDA(
                    r,c,
                    MOD(c-1,c_cnt)+1
                )
            ),
        INDEX(range,rx,cx)))

REPEAT
ABCDEFGHIJKLMN
2Single Column
3ARepeat Rows:3Repeat Rows:2
4BRepeat Columns:1Repeat Columns:4
5CResult:AResult:AAAA
6BBBBB
7CCCCC
8AAAAA
9BBBBB
10CCCCC
11A
12B
13C
14
15Multiple Column
16W1Repeat Rows:3Repeat Rows:2
17X2Repeat Columns:1Repeat Columns:3
18Y3Result:W1Result:W1W1W1
19Z4X2X2X2X2
20Y3Y3Y3Y3
21Z4Z4Z4Z4
22W1W1W1W1
23X2X2X2X2
24Y3Y3Y3Y3
25Z4Z4Z4Z4
26W1
27X2
28Y3
29Z4
Sheet3
Cell Formulas
RangeFormula
E5:E13E5=REPEAT(A3:A5,E3,E4)
I5:L10I5=REPEAT(A3:A5,I3,I4)
E18:F29E18=REPEAT(A16:B19,E16,E17)
I18:N25I18=REPEAT(A16:B19,I16,I17)
Dynamic array formulas.
 
Upvote 0
Hi, another alternative to replace "slow" MAKEARRAY 😉
AREPT(ar,v,[h]) ar:array, v: vertical repeat, [h]: horiz repeat, if omitted=> 1, can handle blanks
Excel Formula:
=LAMBDA(ar, v, [h],
    LET(
        a, IF(ar = "", "", ar),
        r, ROWS(a),
        c, COLUMNS(a),
        INDEX(a, MOD(SEQUENCE(r * MAX(v, 1)) - 1, r) + 1, MOD(SEQUENCE(, c * MAX(h, 1)) - 1, c) + 1)
    )
)
Book1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
1
2ar=AREPT("A",2,3)<=>=REPT(B3,SEQUENCE(2,3)^0)
3AAAAAAA
4AAAAAA
5v,3,h,omittedv,omitted,h,3v,3,h,3
6ar=AREPT(B7:D10,3,4)ar=AREPT(U7:U9,3)=AREPT(U7:U9,,3)=AREPT(U7:U9,3,3)
7Aa1Aa1Aa1Aa1Aa1aaaaaaaa
8Bb2Bb2Bb2Bb2Bb2bbbbbbbb
9Cc3Cc3Cc3Cc3Cc3cccccccc
10Dd4Dd4Dd4Dd4Dd4aaaa
11Aa1Aa1Aa1Aa1bbbb
12Bb2Bb2Bb2Bb2cccc
13Cc3Cc3Cc3Cc3aaaa
14Dd4Dd4Dd4Dd4bbbb
15Aa1Aa1Aa1Aa1cccc
16Bb2Bb2Bb2Bb2
17blankCc3Cc3Cc3Cc3v,3,h,omittedv,omitted,h,3
18empty stringDd4Dd4Dd4Dd4ar=AREPT(U19:W19,3)=AREPT(U19:W19,,3)
19abcabcabcabcabc
20v,omitted,h,4abc
21ar=AREPT(B22:D25,,4)abcv,3,h,3
22Aa1Aa1Aa1Aa1Aa1=AREPT(U19:W19,3,3)
23Bb2Bb2Bb2Bb2Bb2abcabcabc
24C3C3C3C3C3abcabcabc
25Dd4Dd4Dd4Dd4Dd4abcabcabc
26
27v,3,h,omittedrepeat patterns
28=AREPT(B22:D25,3)=AREPT(SEQUENCE(3,4),4,3)
29Aa1123412341234
30Bb2567856785678
31C3910111291011129101112
32Dd4123412341234
33Aa1567856785678
34Bb2910111291011129101112
35C3123412341234
36Dd4567856785678
37Aa1910111291011129101112
38Bb2123412341234
39C3567856785678
40Dd4910111291011129101112
41
Sheet1
Cell Formulas
RangeFormula
G2,T28,G28,AD22,G21,AD18,Y18,AF6,W6,AA6,G6,L2G2=FORMULATEXT(G3)
G3:I4G3=AREPT("A",2,3)
L3:N4L3=REPT(B3,SEQUENCE(2,3)^0)
G7:R18G7=AREPT(B7:D10,3,4)
W7:W15W7=AREPT(U7:U9,3)
AA7:AC9AA7=AREPT(U7:U9,,3)
AF7:AH15AF7=AREPT(U7:U9,3,3)
Y19:AA21Y19=AREPT(U19:W19,3)
AD19:AL19AD19=AREPT(U19:W19,,3)
G22:R25G22=AREPT(B22:D25,,4)
AD23:AL25AD23=AREPT(U19:W19,3,3)
G29:I40G29=AREPT(B22:D25,3)
T29:AE40T29=AREPT(SEQUENCE(3,4),4,3)
Dynamic array formulas.
 
It's funny. The original post was only a few months ago. But, I can't even remember the last time I used 'MAKEARRAY'.

(y) for all of the insights. Always interested in seeing better/more efficient ways of making these formulas!
 

Forum statistics

Threads
1,215,133
Messages
6,123,235
Members
449,092
Latest member
SCleaveland

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