excel formula help or VBA

Job ID: 36907411

Budget: $15 – $25 CAD

Im going to try to explain

I need help generating a formula that will work for data set of 2000 rows and it should be fast. The solution can be VBA or excel formula.

First formula is highlighted in column G

The formula will need to do the following. I need excel to generate the results taking into consideration the description in column c. The reason why I need the formula to look at the description because the names could be sorted in different order. Currently my formula just reference cells but I want it look up the value based on the description in C (Unplanned Energy+Unplanned X)/(reg-Planned Energy)

second formula:
Using the values in column G I need the formula SUMIF based on two conditions it will need to sum the previous 18 months including the current and the months based on the current row/Period in column A. Second condition is it should only sum the last 18 months where the location matches. Please note in my sample data I don't have 18 months of data but actual data will.