Home » excel » google sheets – How to print in excel with iteration per column based on value (number)

# google sheets – How to print in excel with iteration per column based on value (number)

Questions:

I am trying to achieve something that increments per column based on the value given.
Like,

``````if A1 = "ABC" and B1 = 3 then C1 = "ABC", D1 = "ABC" and E1 = "ABC".
If A1 = "ABC" and B1 = 1 then C1 = "ABC"
If A1 = "ABC" and B1 = 2 then C1 = "ABC" and D1 = "ABC"
``````

I haven’t tried anything yet, I only have the logic.

I have seen some codes but it’s VB, what i was trying to achieve was using formula.

Expected output is what above describes.

Thanks

Excel

In cell `C1`:

``````=IF(COLUMN(A1)<=\$B1,\$A1,"")
``````

Drag right till the max you think you must go based on `B1`

In cell `C1`:

``````=ARRAYFORMULA(IF((COLUMN(C1:KN1)-2)<=B1,A1,""))
``````

Change `KN1` to whichever column would be the max and enter.

``````=ArrayFormula(if(column(C1:indirect(address(counta(A:A),max(B:B)+2)))>B:B+2,"",A:A))
``````=ArrayFormula(if(A:A="","",split(rept(A:A&"|",B:B),"|")))