Finding last match

darlbiln

New Member
Joined
Jul 26, 2013
Messages
2
I came up with this formula to find matches in another file which I cannot edit:

=MATCH("*"&A2&"*",'[F4 2006_ECO Log.xls]ECO Log'!$D:$D,0)

It works fine, except I want to find the last match in column D (there are something like 3 total matches). Match seems to return only the first match. I looked at inverting column D, but could not find an easy way to do this within the match formula.

Constraints: I cannot edit the other file.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
hi and welcome to the board

Try like below ( Confirm With CTRL + SHIFT + ENTER )

=MAX(('[F4 2006_ECO Log.xls]ECO Log'!$D:$D="*&A2&*")*ROW('[F4 2006_ECO Log.xls]ECO Log'!$D:$D))-ROW('[F4 2006_ECO Log.xls]ECO Log'!$D$1)+1
 
Upvote 0
I came up with this formula to find matches in another file which I cannot edit:

=MATCH("*"&A2&"*",'[F4 2006_ECO Log.xls]ECO Log'!$D:$D,0)

It works fine, except I want to find the last match in column D (there are something like 3 total matches). Match seems to return only the first match. I looked at inverting column D, but could not find an easy way to do this within the match formula.

Constraints: I cannot edit the other file.

Looks like you want the native row number of the row at which the last match occurs. if so:

=LOOKUP(9.99999999999999E+307,SEARCH(A2,'[F4 2006_ECO Log.xls]ECO Log'!$D:$D),ROW('[F4 2006_ECO Log.xls]ECO Log'!$D:$D)
 
Upvote 0
Thank you both for responding.

Kevatarvind I was not able to get your formula to work. I am not sure why. Can you use $D:$D="*&A2&*" in place of match?

Aladin Akyurek, your formula worked. At first I was wondering why you entered such a large number for the lookup value, but then I found in another post:
  • If the LOOKUP function can not find an exact match, it chooses the largest value in the lookup_range that is less than or equal to the value.
This must be what this formula is exploiting. Very clever, thanks!
 
Upvote 0
Thank you both for responding.

Kevatarvind I was not able to get your formula to work. I am not sure why. Can you use $D:$D="*&A2&*" in place of match?

Aladin Akyurek, your formula worked. At first I was wondering why you entered such a large number for the lookup value, but then I found in another post:
  • If the LOOKUP function can not find an exact match, it chooses the largest value in the lookup_range that is less than or equal to the value.
This must be what this formula is exploiting. Very clever, thanks!

You are welcome. Yes, it exploits the undelying algorithm. Here is some additional info:

http://www.mrexcel.com/forum/excel-questions/102091-9-9999999-a.html
http://www.mrexcel.com/forum/excel-questions/99621-lookup-value-unsorted-data.html
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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