15minoffame
New Member
- Joined
- Nov 26, 2014
- Messages
- 47
Hi to Excel experts,
I hired someone about two years ago to write a macro for me in Excel. The purpose is to show seasonality in stocks. I discovered too late that he used the incorrect formula in calculating the return of a stock on an annual basis.
I have a tab call Calendar and it looks like this. Each row shows the return of a stock for that particular month in that year.
<tbody>
</tbody>
The formula where the error is in the Annual column. It's supposed to take the last closing price of X day subtract closing price on 12/31 of previous year. Instead, this was the formula he came up with.
If MonthColumn = 13 Or ArrayNum = Counter - 1 Then
Cells(row, 14).Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-12]:RC[-1])"
I don't know how to edit this to reference the prices in the Annual Prices tab (shown below) which would give me the correct result. These are the year end closing prices for Apple from 2006-2015 and the actual results. As you can see, they're way off due to the incorrect formula used.
<tbody>
</tbody>
Thanks for ANY suggestions!
Tuan
I hired someone about two years ago to write a macro for me in Excel. The purpose is to show seasonality in stocks. I discovered too late that he used the incorrect formula in calculating the return of a stock on an annual basis.
I have a tab call Calendar and it looks like this. Each row shows the return of a stock for that particular month in that year.
Stock: | AAPL | <tbody> </tbody> | |||||||||||||||||
Year | JAN | FEB | MAR | APR | MAY | JUN | JUL | AUG | SEP | OCT | NOV | DEC | ANNUAL | W | L | PERCENT | AVG GAIN | STREAK | |
2016 | -7.52% | -0.13% | 12.72% | -13.99% | 7.18% | -4.27% | 9.01% | 2.37% | 6.55% | 11.91% | 5 | 4 | 55.56% | 1.32% | 3 | ||||
2015 | 6.14% | 10.08% | -3.14% | 0.58% | 4.53% | -3.72% | -3.29% | -6.62% | -2.18% | 8.34% | -0.58% | -11.02% | -0.88% | 5 | 7 | 41.67% | -0.07% | ||
2014 | -10.77% | 5.75% | 2.00% | 9.94% | 7.87% | 2.77% | 2.87% | 7.75% | -1.71% | 7.20% | 10.60% | -7.19% | 37.08% | 9 | 3 | 75.00% | 3.09% | ||
2013 | -14.41% | -2.53% | 0.29% | 0.03% | 2.24% | -11.83% | 14.12% | 8.38% | -2.15% | 9.64% | 7.01% | 0.89% | 11.67% | 8 | 4 | 66.67% | 0.97% | ||
2012 | 12.71% | 18.83% | 10.53% | -2.60% | -1.07% | 1.09% | 4.58% | 9.39% | 0.28% | -10.76% | -1.24% | -9.07% | 32.67% | 7 | 5 | 58.33% | 2.72% | ||
2011 | 5.20% | 4.09% | -1.33% | 0.47% | -0.66% | -3.50% | 16.33% | -1.45% | -0.91% | 6.15% | -5.58% | 5.97% | 24.78% | 6 | 6 | 50.00% | 2.06% | ||
2010 | -8.86% | 6.54% | 14.85% | 11.10% | -1.61% | -2.08% | 2.27% | -5.50% | 16.72% | 6.07% | 3.38% | 3.67% | 46.55% | 8 | 4 | 66.67% | 3.88% | ||
2009 | 5.60% | -0.91% | 17.70% | 19.70% | 7.93% | 4.87% | 14.72% | 2.95% | 10.19% | 1.70% | 6.05% | 5.41% | 95.92% | 11 | 1 | 91.67% | 7.99% | ||
2008 | -31.66% | -7.64% | 14.78% | 21.22% | 8.51% | -11.29% | -5.07% | 6.66% | -32.96% | -5.34% | -13.87% | -7.90% | -64.56% | 4 | 8 | 33.33% | -5.38% | ||
2007 | 1.05% | -1.31% | 9.81% | 7.42% | 21.43% | 0.70% | 7.97% | 5.10% | 10.83% | 23.77% | -4.07% | 8.70% | 91.40% | 10 | 2 | 83.33% | 7.62% | ||
2006 | 5.04% | -9.30% | -8.43% | 12.23% | -15.09% | -4.18% | 18.67% | -0.16% | 13.46% | 5.33% | 13.05% | -7.44% | 23.17% | 6 | 6 | 50.00% | 1.93% |
<tbody>
</tbody>
The formula where the error is in the Annual column. It's supposed to take the last closing price of X day subtract closing price on 12/31 of previous year. Instead, this was the formula he came up with.
If MonthColumn = 13 Or ArrayNum = Counter - 1 Then
Cells(row, 14).Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-12]:RC[-1])"
I don't know how to edit this to reference the prices in the Annual Prices tab (shown below) which would give me the correct result. These are the year end closing prices for Apple from 2006-2015 and the actual results. As you can see, they're way off due to the incorrect formula used.
2006 11.10 18.01% | |
2007 25.91 133.47% | |
2008 11.16 -56.91% | |
2009 27.56 146.90% | |
2010 42.19 53.07% | |
2011 52.97 25.56% | |
2012 70.22 32.57% | |
2013 75.89 8.07% | |
2014 106.71 40.62% | |
2015 103.50 -3.01% |
<tbody>
</tbody>
Thanks for ANY suggestions!
Tuan