Define a spreadsheet range using two named variables
I am trying to build a quick and dirty way of calculating the IRR for a series of share investments.
Data
A B C
1 Share1 -1000 1/1/2012 buy
2 Share1 50 1/6/2012 dividend
3 Share1 900 1/5/2014 current value
4 Share2 -2000 4/2/2012 buy
5 Share2 60 9/9/2012 div
6 Share2 70 1/1/1013 div
7 Share2 2500 1/5/2014 current value
8 Share3 …
I copy this table of data from a query in an access database
I paste it into excel
I want the IRR for investment in each share
I do not know how many cash movements will be involved with any share
This works
IRR = XIRR(B4:B7, C4:C7, 8)
I can manually retype the range for each share1, then share2, then ...
I would like to save some of this typing
I tried the following - but it gave an error
RowFirst = 4
RowLast = 7
IRR = XIRR(B[RowFirst]:B[RowLast], C[RowFirst]:C[RowLast], 8)
Is there an easy way for me to define the cashflow range and the date range for each company one after the other
Could I use visual basic code?
From within VB there seems to only be the IRR function which is for periodic cash movements
From the spreadsheet there is XIRR that handles a series of dates and cash movements
Using ms Excel 2007
|