MATCH to find last occurence

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
592
Office Version
  1. 365
Platform
  1. Windows
Hello

Can you explain please how does =MATCH(2,1/(A1:A10="a")) enables to find last occurence of "a" ?

I mean the lookup array can be something like: {#DIV/0!; 1; #DIV/0!; 1; #DIV/0!; 1; #DIV/0!; #DIV/0!; #DIV/0!; 1}.

Then, MATCH should find the "first occurence that is <2", which is position 2. Why though it finds the "last occurence that is <2"?

Also, do you know any alternative methods to search for first/last occurence and search forwards/backwards? I know XLOOKUP has such functionality but it may not be available in the local machine.

Thanks!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hello

Can you explain please how does =MATCH(2,1/(A1:A10="a")) enables to find last occurence of "a" ?

I mean the lookup array can be something like: {#DIV/0!; 1; #DIV/0!; 1; #DIV/0!; 1; #DIV/0!; #DIV/0!; #DIV/0!; 1}.

Then, MATCH should find the "first occurence that is <2", which is position 2. Why though it finds the "last occurence that is <2"?

Also, do you know any alternative methods to search for first/last occurence and search forwards/backwards? I know XLOOKUP has such functionality but it may not be available in the local machine.

Thanks!
When we use =MATCH(2,1/(A1:A10="a"))

1/(A1:A10="a") shall return 1 for every match. But Function is searching for 2 as match so would return the last/maximum value.

You can also use

Excel Formula:
=Lookup(2,1/(A1:A10="a"),A1:A10)

Hope it helps.
 
Upvote 0
do you know any alternative methods to search for first/last occurence and search forwards/backwards?

23 09 09.xlsm
ABC
1bFirst2
2aLast8
3c
4b
5c
6a
7c
8a
9d
10s
Find last
Cell Formulas
RangeFormula
C1C1=AGGREGATE(15,6,(ROW(A1:A10)-ROW(A1)+1)/(A1:A10="a"),1)
C2C2=AGGREGATE(14,6,(ROW(A1:A10)-ROW(A1)+1)/(A1:A10="a"),1)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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