I use ArrayFormula()
to simplify the way I create my reports.
Instead of having to create a reference in each cell (eg. =C1
,=C2
,=C3
,=C4
in each cell, I just use =arrayformula(C1:C4)
in one single cell. It does exactly same job, but is much simpler and it keeps things more organized, because I just need to look in one cell for possible errors.
It works great when I have to reference a range into another like take the values of C1:C4 into the A1:A4 range. In the A1 cell I would just write =arrayformula(C1:C4)
and it does its magic.
It does get a bit trickier when the ranges are not the same length, but it is feasible nonetheless. For instance, if I want to stack two or more range link C1:C4 on top of B1:B3, on cell A1 I can write =arrayformula({C1:C4;B1:B3})
.
My problem is using arrayFormula()
to copy a repeating pattern. For instance, if I want to copy the content of cell C1 4 times I would use =arrayformula({C1;C1;C1;C1})
.
This would work and would achieve the desired effect. However, I was wondering if there is a better way to do that. Something like =arrayformula({C1}*12)
were this pattern would repeat 12 times. This would also enable me to have a dynamic formula, such as =arrayformula({C1}*count(D:D))
where the pattern would repeat according to some variable.
Do you have any ideia on how to achieve that using only native formula (no javascript)?
I would use split() function instead of arrayformula() and rept() function to repeat cell positions. For example, if your n=4 the formula will look like this:
rept() repeats cell position C1+semicolon four times creating a string and split() function divides created string by semicolons to horizontal cells.
You can rotate resulted horizontal table to vertical table using transpose() function:
And yes, you can use it to create dynamic formulas with help of arrayformula() function:
This approach won't work when C1 contains a Text Value.
I've come up with a variation to dynamically repeat / fill down a text value in-line with content from another column: