MATCH to find last occurence

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
591
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,215,086
Messages
6,123,031
Members
449,092
Latest member
ikke

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