Dynamic XIRR using offset match (or any other formula)

ExcelUser18

New Member
Joined
May 3, 2017
Messages
40
I have data set below where the first date is cell G33 and its a range from G33:X33. The first cashflow is cell G40 and the range is from G40:X40. Not shown below is a date of reference in Cell F42 that I need to change in order to hopefully make the formula dynamic but ultimately the date in cell F42 should be updated so as to reference it in range G33:X33 and calculate the XIRR with the corresponding cashflows. Note that while I'm showing 18 months here (F42 = 9/1/2027), if I changed the date to 12/1/2026, all the columns would hide (i.e. if cell is greater than 12/1/2026, "") and there would be positive cash flow in the same column which help calculate XIRR on its own.

I checked ChatGPT and my companies internal chatbot and was given 2 different formulas below, both which are not working. Can anyone give any insight as to why they might not be working? Note if I run a regular XIRR through 18 months, it works fine, calculating to a 25.3% result. But when folding in the two formulas below, it does not work. I'm not married to these formulas so I can use something else if its easier and does what I need.

ChatGPT:
Formula:
XIRR(OFFSET(G40, 0, MATCH(F42, G33:X33, 0)-1, 1, COUNTA(G40:X40)-MATCH(F42, G33:X33, 0)+1), OFFSET(G33, 0, MATCH(F42, G33:X33, 0)-1, 1, COUNTA(G33:X33)-MATCH(F42, G33:X33, 0)+1))
Error: #N/A

Work Chatbot:
Formula:
XIRR(OFFSET($G$40, 0, MATCH($F$42, $G$33:$X$33, 0)-1, 1, COUNT($G$33:$X$33)), OFFSET($G$40, 0, MATCH($F$42, $G$33:$X$33, 0)-1, 1, COUNT($G$33:$X$33)))
Error: #NUM!

Date
4/1/2026
5/1/2026
6/1/2026
7/1/2026
8/1/2026
9/1/2026
10/1/2026
11/1/2026
12/1/2026
1/1/2027
2/1/2027
3/1/2027
4/1/2027
5/1/2027
6/1/2027
7/1/2027
8/1/2027
9/1/2027
Year
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
Month
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Expense #1
-$11,660,440
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
Expense #2
-$6,173,198
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
Expense #3
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
Income #1
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$0
$27,283,506
Total Cashflow
-$17,961,810
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
-$128,172
$27,155,334
 
Here's a formula that does work - highlighted.

I have also shown the values and dates for the correct, and for the two incorrect, formulae. (Depending on your Excel version, you may not get the numbers spilling along the row, as shown below).

The ChatGPT formula points to a single value and single date. The ChatBot points to two identical rows of values, starting rather than ending with the September 2027 value.

FGHIJKLMNOPQRSTUVWX
33Date1 Apr 20261 May 20261 Jun 20261 Jul 20261 Aug 20261 Sep 20261 Oct 20261 Nov 20261 Dec 20261 Jan 20271 Feb 20271 Mar 20271 Apr 20271 May 20271 Jun 20271 Jul 20271 Aug 20271 Sep 2027
34Year111111111111222222
35Month123456789101112131415161718
36Expense #1-11,660,44000000000000000000
37Expense #2-6,173,19800000000000000000
38Expense #3-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172
39Income #10000000000000000027,283,506
40Total Cashflow-17,961,810-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,17227,155,334
41
421 Sep 2027
43Correct
44Values-17,961,810-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,172-128,17227,155,334
45Dates1 Apr 20261 May 20261 Jun 20261 Jul 20261 Aug 20261 Sep 20261 Oct 20261 Nov 20261 Dec 20261 Jan 20271 Feb 20271 Mar 20271 Apr 20271 May 20271 Jun 20271 Jul 20271 Aug 20271 Sep 2027
4625.3%
47
48Chat GPT
49Values27,155,334
50Dates1 Sep 2027
51
52WorkBot
53Values27,155,33400000000000000000
54Dates27,155,33400000000000000000
Sheet1
Cell Formulas
RangeFormula
G40:X40G40=SUM(G36:G39)
G44:X44G44=G40:INDEX(G40:X40,MATCH(F42,G33:X33,))
G45:X45G45=G33:INDEX(G33:X33,MATCH(F42,G33:X33,))
G46G46=XIRR(G40:INDEX(G40:X40,MATCH(F42,G33:X33,)),G33:INDEX(G33:X33,MATCH(F42,G33:X33,)))
G49G49=OFFSET(G40, 0, MATCH(F42, G33:X33, 0)-1, 1, COUNTA(G40:X40)-MATCH(F42, G33:X33, 0)+1)
G50G50=OFFSET(G33, 0, MATCH(F42, G33:X33, 0)-1, 1, COUNTA(G33:X33)-MATCH(F42, G33:X33, 0)+1)
G53:X54G53=OFFSET($G$40, 0, MATCH($F$42, $G$33:$X$33, 0)-1, 1, COUNT($G$33:$X$33))
Dynamic array formulas.
 
Upvote 0
wow this is great; I was overthinking it. A friend suggested index/match but thought offset was the way to go. very much appreciated, thank you
 
Upvote 0

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