XIRR with a dynamic range

DWig

Board Regular
Joined
Sep 26, 2012
Messages
77
Hello all, I'm back.

I am trying to calculate the XIRR for a series of projects, and the timing of cash flows changes on them. However, the cash flows will always be in row 48, and the months will always be in row 5. The ending period (which can extend in XIRR past the last cash flow, so it doesn't have to be dynamic) is always in column HQ.

The correct XIRR formula is as follows:

=XIRR(EK48:$HQ$48,EK5:$HQ$5)

I can get a dynamic beginning cash flow value as follows:
=ADDRESS(5,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))

This gives me the value $EK$5, which is correct.

The dynamic beginning month value would be as follows:
=ADDRESS(48,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))

This gives me the value $EK$48, which is correct.

However, trying to add them together as follows:

=XIRR(ADDRESS(48,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0)))):$HQ$48,ADDRESS(5,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0)))):$HQ$5)

Gives me the following error message and doesn't allow the formula to be confirmed:
"The formula you typed contains an error.
-For information about fixing common problems, click Help.
-To get assistance in entering a function, click Function Wizard (Formulas tab, Function Library group).
-If you are no trying to enter a formula, avoid using an equal sign (=) or minus sign(-), or precede it with a single quotation mark (')."


I've tried a couple different methods of concatenation and quotation marks with limited success. For example:
=XIRR(ADDRESS(48,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))&":$HQ$48",ADDRESS(5,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))&":$HQ$5")
Allows the formula to be confirmed. However, the result is a #VALUE! error. When I show the calculation steps, it shows the following:

"XIRR("$EK$48:$HQ$48","$EK$5:$HQ$5")
The next evaluation will result in an error."

I'm not really sure where the problem is. I also tried removing the absolute references in the "address" functions with the same error, but didn't include it for the sake of brevity. Any guidance would be very much appreciated.

Thanks,
DWig
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try (untested):

=XIRR(INDIRECT(ADDRESS(48,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))&":$HQ$48"),INDIRECT(ADDRESS(5,COLUMN(INDEX(J48:HQ48,MATCH(TRUE,INDEX(J48:HQ48<>0,0),0))))&":$HQ$5"))
 
Upvote 0
That worked like a charm. Thanks a bunch! So any time you're making an equation part of a cell reference, you have to use "indirect"?
 
Upvote 0
Hi,

For an alternative way to write your formula perhaps try something like this:

In A1 (using CTRL-SHIFT-ENTER rather than just ENTER):
Code:
=MATCH(TRUE, J48:HQ48 <> "", 0)
In A2 (with just ENTER):
Code:
=XIRR(
    INDEX(J48:HQ48, A1):$HQ$48,
    INDEX(J5:HQ5, A1):$HQ$5)

  • This uses the colon range reference operator.
  • You can change A1 to avoid CTRL-SHIFT-ENTER as your original version does but it may perform a little less efficiently.
  • You could also incorporate the formula from A1 into a single formula, but again it may be a little less efficient (and a bit harder to read).
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top