veryamusing
New Member
- Joined
- Jul 28, 2017
- Messages
- 28
I have a custom function to calculate NPV, which is called every time one of several cells changes (to avoid circular references, since the user doesn't want to use iterative calculation). The initial result is always slightly off; however, if I reenter the same value in any of the target cells, the value converges to the correct value after five to ten tries.
The only fix I could thing of was looping the action of editing / entering the target cell, but doing this in VBA doesn't cause the sheet to recalculate. Initially I thought the issue was caused by setting enable events to false in the worksheet change sub, but that doesn't seem to make any difference. I think the problem is the fact that NPV is based on a rate of interest that changes based on the weighted average life, which is based on NPV! So, NPV >> WAL >> Rate, NPV >> WAL >> Rate, etc. That's why an earlier version of this used iterative calculation.
[TABLE="width: 500, align: center"]
<tbody>[TR]
[TD]79,392,713[/TD]
[TD]21.7[/TD]
[TD]3.83%[/TD]
[/TR]
[TR]
[TD]79,595,408[/TD]
[TD]21.5[/TD]
[TD]3.82%[/TD]
[/TR]
[TR]
[TD]79,660,470[/TD]
[TD]21.511[/TD]
[TD]3.8232%[/TD]
[/TR]
</tbody>[/TABLE]
Any ideas would be appreciated!
The only fix I could thing of was looping the action of editing / entering the target cell, but doing this in VBA doesn't cause the sheet to recalculate. Initially I thought the issue was caused by setting enable events to false in the worksheet change sub, but that doesn't seem to make any difference. I think the problem is the fact that NPV is based on a rate of interest that changes based on the weighted average life, which is based on NPV! So, NPV >> WAL >> Rate, NPV >> WAL >> Rate, etc. That's why an earlier version of this used iterative calculation.
[TABLE="width: 500, align: center"]
<tbody>[TR]
[TD]79,392,713[/TD]
[TD]21.7[/TD]
[TD]3.83%[/TD]
[/TR]
[TR]
[TD]79,595,408[/TD]
[TD]21.5[/TD]
[TD]3.82%[/TD]
[/TR]
[TR]
[TD]79,660,470[/TD]
[TD]21.511[/TD]
[TD]3.8232%[/TD]
[/TR]
</tbody>[/TABLE]
Any ideas would be appreciated!