Match function in reverse direction

DrDebit

Board Regular
Joined
May 20, 2013
Messages
123
Office Version
  1. 365
Platform
  1. Windows
Is it possible to use the MATCH function to find the ordinal position of text, but going up instead of going down.

X
Y
Program
A
B
C
Program
R
S
Here

In the cell with "Here" in it, I want to be able to find the position of the first time that the word, "Program," appears, but going up instead of down.

Thank you!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
My thought is that the OP wants the formula in the cell marked "here". As you said, we need more clarification.
 
Upvote 0
I guess Mr OP is looking for something similar to this.


Excel 2013/2016
AB
1DataPosition
2X6
3Y
4Program
5A
6B
7C
8Program
9R
10S
11A
12R
13Program
14R
15A
16C
17R
18R
19Here
20R
21R
22S
23C
24Program
Sheet1
Cell Formulas
RangeFormula
B2=COUNTA(INDIRECT("A"&MATCH("Here",A2:A50,0)+1):INDEX(INDIRECT("A2:A"&MATCH("Here",A2:A50,0)),LOOKUP(2,1/(INDIRECT("A2:A"&MATCH("Here",A2:A50,0))="Program"),ROW(INDIRECT("A2:A"&MATCH("Here",A2:A50,0)))-MIN(ROW(INDIRECT("A2:A"&MATCH("Here",A2:A50,0)))))+1))-1
 
Last edited:
Upvote 0
You have had a number of replies, which one are you referring to?
 
Upvote 0
Thank you, Eric. This works...in theory...

The problem that I am having is while I get the correct result, it shows up in the cell as a 0. I have checked the function dialogue box, as well as the F9 trick. For both, I get the right answers, but in the cell, I keep getting 0. I have checked the formatting dialogue box, and it keeps coming up 0. Any ideas? Thank you again so much!
 
Upvote 0
That's a poser, I don't know quite what to tell you. Try copying the cell with the formula, then select a cell somewhere that has nothing in it and no formatting, and do a Paste Special > Values, and see what you get. That should tell us if it's a formula or formatting issue. Have you tried looking at the Evaluate Formula tool? Select the cell with the formula, then go to the Formula tab, and click Evaluate Formula, and step through it and see what happens. If that doesn't give any enlightenment, try Toadstool's formula from post 4. It's the same basic idea as mine, but it uses a different function that might work differently.
 
Upvote 0
Thank you for your patience. I had the cell range to include the cell that it was looking for. When I used the range excluding the "here" cell it worked.

As I told you, the strange thing is when doing the F9 evaluate, I got the right answer, but in the cell, it came up 0.

Regardless, I so appreciate your time and attention to this matter...as well as all the other that helped.

Thank you one and all!!!

Dr. Debit
 
Upvote 0
try Toadstool's formula from post 4.

Actually I'd misunderstood the question and was giving the last entry for "Project".

If OP needs the last "Project" before "Here" then I think this is it:

AB
1DataPosition
2X10
3Program
4A
5B
6C
7Program
8R
9R
10Program
11R
12R
13Here
14R
15Program

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=AGGREGATE(14,6,ROW(INDIRECT("$A$1"&":"&ADDRESS(MATCH("Here",$A$1:$A$15,0),1)))/($A$1:$A$15="Program"),1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Thank you one and all...it has helped me so much. Kudos and thanks!!
 
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