Please have a look at the following Google spreadsheet:

https://docs.google.com/spreadsheets...it?usp=sharing

Columns B and C are dynamic (number of lines always growing)

I believe Column E and my comment on cell E15 are self explanatory to show what I would like to achieve.

Many thanks for any kind help.

Octavio