I created an area that would be automatically populated with the number of rows that you call for in cell D6. The data is drawn from your sample in C13:D21. In C26 enter and fill down:
This is an Array Formula:...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
In D26 enter this formula and fill down:
Here is your workbook. You can test it out to see how it works.
Bookmarks