Dear experts,
I have random securities in column B with a respective value in column C. I want to calculate the profit I made if I sell the security. However, I only sell if the security in column B changes in the following row. Otherwise I hold the security and the profit is zero (or empty, not relevant). Here is an example. I start with 100 and the periods increase with rows, i.e. I compute profit by calculating from bottom to top.
[TABLE="class: grid"]
<tbody>[TR]
[TD]Month (=A1)[/TD]
[TD]Security[/TD]
[TD]Value[/TD]
[TD]Profit[/TD]
[TD]Calculation[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]30/09/2011[/TD]
[TD]Bond[/TD]
[TD]91.49[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]31-Oct-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.65[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]30-Nov-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.80[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]31-Dec-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.95[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]31-Jan-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]92.10[/TD]
[TD]-7.90[/TD]
[TD]C7-C2[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]29-Feb-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]S&P[/TD]
[TD]95.67[/TD]
[TD]3.56[/TD]
[TD]C8-C7[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]31-Mar-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Dow[/TD]
[TD]96.92[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]30-Apr-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Dow[/TD]
[TD]94.32[/TD]
[TD]-1.35[/TD]
[TD]C10-C8[/TD]
[/TR]
</tbody>[/TABLE]
I want to find the formula for the profit. The table continues for various periods, so the securities repeat themselves randomly. I tried to use INDEX with counting the number of time a security appears until it changes but it did not work. COUNTIF until value in column B changes didn't work either since it counts all values in the entire table, not just the ones until the security changes.
I could not find a forum entry in this respect.
Many thanks for your help.
I have random securities in column B with a respective value in column C. I want to calculate the profit I made if I sell the security. However, I only sell if the security in column B changes in the following row. Otherwise I hold the security and the profit is zero (or empty, not relevant). Here is an example. I start with 100 and the periods increase with rows, i.e. I compute profit by calculating from bottom to top.
[TABLE="class: grid"]
<tbody>[TR]
[TD]Month (=A1)[/TD]
[TD]Security[/TD]
[TD]Value[/TD]
[TD]Profit[/TD]
[TD]Calculation[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]30/09/2011[/TD]
[TD]Bond[/TD]
[TD]91.49[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]31-Oct-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.65[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]30-Nov-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.80[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]31-Dec-2011[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]91.95[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]31-Jan-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Bond[/TD]
[TD]92.10[/TD]
[TD]-7.90[/TD]
[TD]C7-C2[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]29-Feb-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]S&P[/TD]
[TD]95.67[/TD]
[TD]3.56[/TD]
[TD]C8-C7[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84"]31-Mar-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Dow[/TD]
[TD]96.92[/TD]
[TD]0[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD][TABLE="width: 84"]
<tbody>[TR]
[TD="class: xl65, width: 84, align: right"]30-Apr-2012[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Dow[/TD]
[TD]94.32[/TD]
[TD]-1.35[/TD]
[TD]C10-C8[/TD]
[/TR]
</tbody>[/TABLE]
I want to find the formula for the profit. The table continues for various periods, so the securities repeat themselves randomly. I tried to use INDEX with counting the number of time a security appears until it changes but it did not work. COUNTIF until value in column B changes didn't work either since it counts all values in the entire table, not just the ones until the security changes.
I could not find a forum entry in this respect.
Many thanks for your help.