Reinitialize a RANGE object in VBA

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Hi, again...now another question

I would like to write a function:
Public Function NetPV(CashFlows As Range, drate As Double, period As Integer) As Variant

All I need is the ability to change the contents of the Range array, CashFlows depending on the
period. Is it possible to do so?

For example if CashFlows has 7 cell references in it and I just need the first 2:
CashFlows = (CashFlows(1), CashFlows(2))

I know this doesn't work as the compiler has a fit.

Any ideas?

Thank you all so much,

Rick
 
Hi Rick,
One way.
Public Function NetPV( drate As Double, period As Integer) As Variant
Dim CashFlows as range
Set CashFlows = Selected 'cells selected with mouse
Debug.print CashFlows.Address, CashFlows.rows.count,
CashFlows.rows(2).address, CashFlows.rows(2).value


--
John
johnf 202 at hotmail dot com


| Hi, again...now another question
|
| I would like to write a function:
| Public Function NetPV(CashFlows As Range, drate As Double, period As
Integer) As Variant
|
| All I need is the ability to change the contents of the Range array,
CashFlows depending on the
| period. Is it possible to do so?
|
| For example if CashFlows has 7 cell references in it and I just need the
first 2:
| CashFlows = (CashFlows(1), CashFlows(2))
|
| I know this doesn't work as the compiler has a fit.
|
| Any ideas?
|
| Thank you all so much,
|
| Rick
 
Back
Top