Create rows from values with Excel formula

cekar :

Is it possible with Excel formula to translate a "record" into multiple rows? Let's say I have column A and B and want to translate it to achieve values showing in column D & E enter image description here

Thanks for your help!

Scott Craner :

Put this in D2 and copy down till you get blanks:

=IF(ROW(A1)<=SUM(B:B),INDEX($A$2:$A$4,MATCH(ROW(A1)-1,SUMIF(OFFSET($B$1,0,0,ROW($B$2:$B$4)-MIN(ROW($B$2:$B$4))+1,),">0"))),"")

Depending on one's version, this may require the formula be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Then put this in E2 and copy down:

=IF(D2<>"",COUNTIFS($D$2:D2,D2),"")

enter image description here


If one has the Dynamic Array Formula SEQUENCE() then the first Formula can be replaced with:

=INDEX($A$2:$A$4,MATCH(SEQUENCE(SUM(B:B),,0),SUMIF(OFFSET($B$1,0,0,SEQUENCE(COUNT(B:B)),),">0")))

Put that in D2 and Excel will spill the results down.

The second formula would become:

=COUNTIFS(OFFSET($G$1,1,0,SEQUENCE(COUNTA(D2#)),),D2#)

Again put that in E2 and Excel will spill down the results.

enter image description here

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=383480&siteId=1