This is maybe a bit much but you can do it like this.
Start in Column K and run a Count starting at 1 and go until you have the number of records you want to return.
Then in Column M I am copying that range and pasting it below the previous set, do this 4 times in this case.
Then in Column O, I have sorted the numbers I just created which leaves me with a one next to the first 4 rows (O2:O5). In your screenshot you have a space between each one thus we need the extra 1.
Then looking at Columns H and I we create our shell, you will copy and paste this down as far as needed.
Then in Columns E and F we are combining the text and the number to make the Z_=Sheet2!B turn into Z_=Sheet2!B1
We then copy and paste Columns E and F and put the Data into Columns B and C and make sure to Paste as Values
You should then be able to simply highlight Columns B and C and use Find / Replace to change Z_ to "" (blank).
Hopefully that makes sense
Still a bit of work but alot easier than manually doing it.
[TABLE="class: grid, width: 700"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]=Sheet2!B1[/TD]
[TD][/TD]
[TD][/TD]
[TD]=IF(H2<>"",CONCATENATE(H2,O2),"")[/TD]
[TD]=IF(I2<>"",CONCATENATE(I2,O2),"")[/TD]
[TD][/TD]
[TD]Z_=Sheet2!B[/TD]
[TD][/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/T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