Max match

gorem

Board Regular
Joined
Sep 28, 2013
Messages
188
Hi all,

I need to return the largest row number in a column which contains a certain value. I am thinking I can use a combination of Max and Match as an array formula, but I'm a little stuck. Imagine the following five values are in column A and I want to return the greatest row number containing "Dog":

Cat
Dog
Dog
Dog
Dog

I would expect the formula to return 5. Any ideas? Thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I think you can get what you want with just the match function.
Excel Workbook
ABC
1CatMax Row #5
2Dog
3Dog
4Dog
5Dog
Sheet
 
Upvote 0
That worked great! Question - I only use Match as part of Index/Match, and I always use 0 as the last term to find exact matches. What exactly does the 1 do? Thanks!
 
Upvote 0
The 0 looks for an exact match and returns the first one it finds. As explained in the help below 1 returns the last value that matches (in this case). So, in your case 0 would return 2.


From Help
[TABLE="class: collapse, width: 99%"]
<tbody>[TR="class: trbgodd"]
[TD="class: noborder, align: left"]1 or omitted[/TD]
[TD="class: noborder, align: left"]MATCH finds the largest value that is less than or equal to lookup_value. The values in the lookup_array argument must be placed in ascending order, for example: ...-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE.
[/TD]
[/TR]
[TR="class: trbgeven"]
[TD="class: noborder, align: left"]0[/TD]
[TD="class: noborder, align: left"]MATCH finds the first value that is exactly equal to lookup_value. The values in the lookup_array argument can be in any order.[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Amazing - thanks so much!

This is enough to get me started. If you have a moment, I'd love to know how to use that formula in VBA with Evaluate, and a variable in place of the actual string "Dog". For instance, if the variable "id" contains the string I'm looking for. I keep getting a type mismatch error.
 
Upvote 0

Forum statistics

Threads
1,224,392
Messages
6,178,322
Members
452,841
Latest member
GenAkaman

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