ikeringillc
New Member
- Joined
- Aug 28, 2018
- Messages
- 2
Hi there, hope someone can help me with this. I've searched previous posts and can find loads of really useful information, but I can;t seem to find a solution to this one
Basically I have data in a sheet that is based on dates across the columns and then rows with values that correspond to those dates. I then use XIRR in an array formula to calculate rates of return between two dates with a formula like this one ...
=XIRR(IF(COLUMN(J9:O9)=COLUMN(J29),-J9,IF(COLUMN(J9:O9)=COLUMN(O9),O9-O29,-J29:O29)),J1:O1)
The above example is calculating the return based on 6 months (J:0) of data. The challenge is to make this period variable (i.e have the number of months as an input) and make it dynamic. I thought this would be relatively straightforward by a combination of address() and column() like this ...
=XIRR(IF(COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))=COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4))),-1*OFFSET(O9,0,-5),IF(COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))=COLUMN(O9),O9-O29,-J29:O29)),J1:O1)
This all seems to work ok until I try and use the exact same principle to then change the reference in RED at follows, at which point I always get a #Value error.
INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))).
If I remove the '-' then I no longer get the error, although clearly the formula will return the wrong result as these values need to be -ve for XIRR to calculate correctly! If I simply test this formula in isolation it seems to work fine, but as part of the formula above it always gets a #Value error.
Any ideas on how I can use this technique and make the values -ve (*-1) of their current value?
Many thanks as I've spent far far far too many hours on this one
Basically I have data in a sheet that is based on dates across the columns and then rows with values that correspond to those dates. I then use XIRR in an array formula to calculate rates of return between two dates with a formula like this one ...
=XIRR(IF(COLUMN(J9:O9)=COLUMN(J29),-J9,IF(COLUMN(J9:O9)=COLUMN(O9),O9-O29,-J29:O29)),J1:O1)
The above example is calculating the return based on 6 months (J:0) of data. The challenge is to make this period variable (i.e have the number of months as an input) and make it dynamic. I thought this would be relatively straightforward by a combination of address() and column() like this ...
=XIRR(IF(COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))=COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4))),-1*OFFSET(O9,0,-5),IF(COLUMN(INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))=COLUMN(O9),O9-O29,-J29:O29)),J1:O1)
This all seems to work ok until I try and use the exact same principle to then change the reference in RED at follows, at which point I always get a #Value error.
INDIRECT(ADDRESS(9,COLUMN()-5,4)&":"&ADDRESS(9,COLUMN())))).
If I remove the '-' then I no longer get the error, although clearly the formula will return the wrong result as these values need to be -ve for XIRR to calculate correctly! If I simply test this formula in isolation it seems to work fine, but as part of the formula above it always gets a #Value error.
Any ideas on how I can use this technique and make the values -ve (*-1) of their current value?
Many thanks as I've spent far far far too many hours on this one