# Graphing cumulative elevation gain along a route

I'm trying to develop a formula that will allow for a graph of the cumulative slope elevation gain along a route to be created. Currently I am using the Max value of the elevation along the route starting from the beginning of the route. This works until I get to the first decline and then it does not include the slope elevation gain for the entire section of positive slope. I am hoping that the graph would start gaining elevation again at a distance of 1535m and again at each point of positive slope (distance values 4578, 6091). Does anyone have any idea on how to solve this in excel without having to manually create cumulative slope points?

• $c_{i+1}=c_i+\max(e_{i+1}-e_i,0)$ – Rahul Sep 19 '13 at 16:43
• Hi Ruhal I have tried to impliment this but I am having difficulty in defining c. – user6784 Sep 19 '13 at 21:39