IF within an INDEX/MATCH?

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
790
Office Version
  1. 365
Platform
  1. Windows
My formula has magically stopped working.. it used to look like this:

=IFERROR(IF(COUNTIF(BookData!O:O,EnqData!Q3)=0,"",INDEX(BookData!B:B,MATCH(Q3,IF(BookData!H:H>=C3,BookData!O:O,""),0),0)),"")


What this does:

First portion - Counts whether the unique customer reference in Q3 matches any references in BookData!O:O. If there are no matching references, the formula terminates.

Second portion - Index Match. This returns the Booking reference (held in B:B) based on a match of Q3 in O:O of Booking Data. However, there is an IF statement inside which says "If the Booking Date (H:H) is greater than or equal to C3 (the enquiry date) then return the match in O:O, otherwise, do nothing.

This formula was working nicely, but after some iterations to my sheets I've noticed it's stopped. I have double checked and ensured that each sheet has the correct references. If I remove the IF statement, the formula works as it should, except now it shows me any booking dates that match the reference, not just ones made after the enquiry (so it's rendered useless for calculating how long it takes customers to book after enquiring)

Thank you!

O:O - Booking Data Customer Reference
B:B - Booking Data Booking Reference
H:H - Booking Data Book Date


Q:Q - Enquiry Data Customer Reference
C:C - Enquiry Data Enquiry Date



I hope this makes sense.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Interestingly, my sheet is 190,000 rows deep. The formula appears to work just fine up until row 81,800, where it then stops giving me a result until I remove the "IF" part of the formula which is embedded in the MATCH... Any ideas?
 
Last edited:
Upvote 0
Here's another clue, the Booking Data sheet is approximately 81,800 rows long, the formula appears to stop working on the enquiry sheet about 81,800 rows in... Are these linked?
 
Upvote 0
I've altered the formula so that every time it references the Enquiry sheet it has an absolute enquiry reference in, such as below:

=IFERROR(IF(COUNTIF(BookData!O:O,EnqData!Q84578)=0,"",INDEX(BookData!B:B,MATCH(EnqData!Q84578,IF(BookData!H:H>=EnqData!C84578,BookData!O:O,""),0),0)),"")

This is still giving me no luck.

I repeat, this used to work, I still have the old values copy-pasted1-2-3 in from where it was working before, I have no idea why this has stopped working.
 
Upvote 0
Could you put the second IF outside the INDEX, something like :-
Code:
[LEFT][COLOR=#333333][FONT=Verdana][LEFT][COLOR=#333333][FONT=Verdana][LEFT][COLOR=#333333][FONT=Verdana]IF(BookData!H:H>=EnqData!C84578,BookData!O:O,[/FONT][/COLOR][/LEFT]INDEX(BookData!B:B,MATCH(EnqData!Q84578,BookData!O:O,0),"")[/FONT][/COLOR][/LEFT]
[/FONT][/COLOR][/LEFT]

hth
 
Upvote 0
Could you put the second IF outside the INDEX, something like :-
Code:
[LEFT][COLOR=#333333][FONT=Verdana][LEFT][COLOR=#333333][FONT=Verdana][LEFT][COLOR=#333333][FONT=Verdana]IF(BookData!H:H>=EnqData!C84578,BookData!O:O,[/FONT][/COLOR][/LEFT]
INDEX(BookData!B:B,MATCH(EnqData!Q84578,BookData!O:O,0),"")[/FONT][/COLOR][/LEFT]
[/FONT][/COLOR][/LEFT]

hth

You know what I suppose that would work - I've had to move on to another project in the short term but I'll be back with a vengeance this afternoon to try that. Thank you!
 
Upvote 0
Perhaps this :-
Code:
=IFERROR(IF(AND(COUNTIF(BookData!O:O,EnqData!Q3)>0,BookData!H:H>=C3),INDEX(BookData!B:B,MATCH(Q3,BookData!O:O,0)),""),"")
for the complete formula.

hth
 
Last edited:
Upvote 0
In case anyone stumbles on this thread... I missed that it needs to be an array formula. This formula was being pasted in then scrubbed as values via VBA and I had it set as Cells (ActiveCell.Row, "R").Formula = "blahblahblah" when it should've been FormulaArray = "blahblahblah"

Somehow, maybe I accidentally deleted it while mucking around, but Array went missing and it caused a blank formula to be overwritten instead.
 
Upvote 0

Forum statistics

Threads
1,215,503
Messages
6,125,179
Members
449,212
Latest member
kenmaldonado

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