Finding the last text value based on cell value in another column

BiggusDoggus

Board Regular
Joined
Jul 7, 2014
Messages
91
Office Version
  1. 365
Platform
  1. Windows
Hi all

So I have a table of data - here is an example:


ABC
1CodeStageFinal Stage
2455Stage 1
3455Stage 2
4522Stage 1
5522Stage 1
6616Stage 1
7616Stage 2
8616Stage 3
9616Stage 4


What I'm wanting in column 3 is a formula to return the stage in column B relating to the last occurrence of the code in column A.

So - for code 455 it would be Stage 2, code 522 Stage 1, code 616 Stage 4.

I can't use MAX obviously because that doesn't work for text values, but I have been unable to locate an alternative.

Any help appreciated please!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about?

Book2
ABCD
1CodeStageFinal Stage
2455Stage 1Stage 2Stage 2
3455Stage 2Stage 2 
4522Stage 1Stage 1Stage 1
5522Stage 1Stage 1 
6616Stage 1Stage 4Stage 4
7616Stage 2Stage 4 
8616Stage 3Stage 4 
9616Stage 4Stage 4 
10
Sheet12
Cell Formulas
RangeFormula
C2:C9C2=LOOKUP(2,1/($A$2:$A$10=A2),$B$2:$B$10)
D2:D9D2=IF(COUNTIF($A$2:$A2,A2)=1,LOOKUP(2,1/($A$2:$A$10=A2),$B$2:$B$10),"")


The D2 formula is if you only want to show the result on the first matching line.
 
Upvote 0
Hi BiggusDoggus,

This formula should do what you ask:

BiggusDoggus.xlsx
ABC
1CodeStageFinal Stage
2455Stage 1Stage 2
3455Stage 2Stage 2
4522Stage 1Stage 1
5522Stage 1Stage 1
6616Stage 1Stage 4
7616Stage 2Stage 4
8616Stage 3Stage 4
9616Stage 4Stage 4
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(A2="","",INDEX($B$2:$B$15,AGGREGATE(14,6,ROW($A$2:$A$15)-ROW($A$1)/($A$2:$A$15=A2),1)))
 
Upvote 0
How about?

Book2
ABCD
1CodeStageFinal Stage
2455Stage 1Stage 2Stage 2
3455Stage 2Stage 2 
4522Stage 1Stage 1Stage 1
5522Stage 1Stage 1 
6616Stage 1Stage 4Stage 4
7616Stage 2Stage 4 
8616Stage 3Stage 4 
9616Stage 4Stage 4 
10
Sheet12
Cell Formulas
RangeFormula
C2:C9C2=LOOKUP(2,1/($A$2:$A$10=A2),$B$2:$B$10)
D2:D9D2=IF(COUNTIF($A$2:$A2,A2)=1,LOOKUP(2,1/($A$2:$A$10=A2),$B$2:$B$10),"")


The D2 formula is if you only want to show the result on the first matching line.
The D2 formula is perfect - thank you!
 
Upvote 0
Do you mean this?

Book1
ABCD
1CodeStageFirst StageFinal Stage
2455Stage 1Stage 1Stage 2
3455Stage 2  
4522Stage 1Stage 1Stage 1
5522Stage 1  
6616Stage 1Stage 1Stage 4
7616Stage 2  
8616Stage 3  
9616Stage 4  
Sheet3
Cell Formulas
RangeFormula
C2:C9C2=IF(COUNTIF($A$2:$A2,A2)=1,B2,"")
D2:D9D2=IF(COUNTIF($A$2:$A2,A2)=1,LOOKUP(2,1/($A$2:$A$10=A2),$B$2:$B$10),"")

That would be it, yes thank you! And to have the value appear on every matching line please?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

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