Here is another approach:
=ArrayFormula(VLOOKUP(TRANSPOSE(SPLIT(JOIN("",REPT(ROW(A:A)&"@",A:A)),"@",0,1)),{ROW(A:A),B:B},2,FALSE))
How It Works
=ArrayFormula(...)
signifies that the formula will process an entire range and not just one cell.
Now, working from the inside out...
REPT(ROW(A:A)&"@",A:A)
will add the @
symbol onto the end of each row number and then repeat that string however many times is listed in A:A. For instance, if row 1 Column A indicates to repeat 1x, the string for that row will be 1@
. If row 2 Column A indicates it is to repeat 2x, the sting for that row will be 2@2@
.
JOIN("",...)
All of those strings will be joined into one long string (e.g., 1@2@2@3@3@3@
...)
SPLIT(...,"@",0,1)
That long string will be split apart at the @
symbol into a long virtual row of individual numbers, e.g.:
1 2 2 3 3 3...
TRANSPOSE(...)
That long virtual row of individual numbers will be transposed into a column of the same numbers, e.g.:
1
2
2
3
3
3
etc.
VLOOKUP(...,{ROW(A:A),B:B},2,FALSE))
Each of those individual numbers in the column will be looked up within a virtual array composed of all row numbers in column one and all B:B text in column two. When each exact match is found (signified by FALSE
), the Column 2
data will be returned.