A
Adrian T
Hi:
I am trying to calculate a Net Present Value of a series
of annual rates (30 years). After I get the NPV result, I
want to populate the next consecutive cells with the
annual rates for over 30 years (when the optional blnOut
is true).
Here's my code:
-----------------------------------------------------
Public Function NPV_LossAdjustmentExp(Optional blnOut As
Boolean) As Double
Dim arrLossAdjustmentExp() As Double
Dim i As Integer
ReDim arrLossAdjustmentExp(1 To 30)
For i = 1 To 30
arrLossAdjustmentExp(i) = Losses.LossAdjustmentExp(i)
Next i
NPV_LossAdjustmentExp = NPV(Assumptions.getNPVRate,
arrLossAdjustmentExp())
If blnOut Then
ActiveCell.Next.Activate
For i = 1 To 30
ActiveCell.Value = arrLossAdjustmentExp(i)
ActiveCell.Next.Activate
Next i
End If
End Function
----------------------------------------------------
The NPV formula works just fine. But the populate command
doesn't work because the cell pointer is still in the same
position. In another word, 'ActiveCell.Next.Activate'
command can't be executed.
Is there a way to execute the NPV calculation, get out
from the cell, move to the next cell, populate it, move to
the next cell, populate it, and so on.
I am not sure if I can do it without completely finishing
the function. So, any other logic is welcome.
Thank you,
Adrian T
I am trying to calculate a Net Present Value of a series
of annual rates (30 years). After I get the NPV result, I
want to populate the next consecutive cells with the
annual rates for over 30 years (when the optional blnOut
is true).
Here's my code:
-----------------------------------------------------
Public Function NPV_LossAdjustmentExp(Optional blnOut As
Boolean) As Double
Dim arrLossAdjustmentExp() As Double
Dim i As Integer
ReDim arrLossAdjustmentExp(1 To 30)
For i = 1 To 30
arrLossAdjustmentExp(i) = Losses.LossAdjustmentExp(i)
Next i
NPV_LossAdjustmentExp = NPV(Assumptions.getNPVRate,
arrLossAdjustmentExp())
If blnOut Then
ActiveCell.Next.Activate
For i = 1 To 30
ActiveCell.Value = arrLossAdjustmentExp(i)
ActiveCell.Next.Activate
Next i
End If
End Function
----------------------------------------------------
The NPV formula works just fine. But the populate command
doesn't work because the cell pointer is still in the same
position. In another word, 'ActiveCell.Next.Activate'
command can't be executed.
Is there a way to execute the NPV calculation, get out
from the cell, move to the next cell, populate it, move to
the next cell, populate it, and so on.
I am not sure if I can do it without completely finishing
the function. So, any other logic is welcome.
Thank you,
Adrian T