Look, mate, you've got to have some idea of what the result in column H should look like for the first few rows of data.

I dont know how to do it so I cant do an example
The idea is that you create the result manually and describe the logic that leads to that result. Then we have a way of creating a formula to create the result and checking against your manual solution to see if it meets the requirements.