How to get last value on row data based on criteria?

mcmuney

Board Regular
Joined
Sep 11, 2015
Messages
101
Office Version
  1. 365
I have a data series, example shown below, what I'm looking is to extract the LAST value on the bottom row based on the criteria of the top row. For example:

If top row = A, show result Grape
If top row = B, show result Apple
If top row = C, show result Banana

* note that range will vary and column data will potentially shift

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD="align: center"]Apple[/TD]
[TD="align: center"]Orange[/TD]
[TD="align: center"]Grape[/TD]
[TD="align: center"]Orange[/TD]
[TD="align: center"]Grape[/TD]
[TD="align: center"]Apple[/TD]
[TD="align: center"]Pear[/TD]
[TD]Banana[/TD]
[/TR]
</tbody>[/TABLE]

Is there a simple formula to achieve this?

Thanks.
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Not exactly sure what your actual set up is....but
with your sample data in A1:H2

This regular formula, copied across, returns the values you're looking for:
Code:
A4: =IFERROR(INDEX(A2:$H2,MATCH(0,INDEX(--(A1:$H1=A1),0),0)-1),$H$2)

These are the results:
Code:
A       A        A       B        B       B       C      C
Apple   Orange   Grape   Orange   Grape   Apple   Pear   Banana
                     
Grape   Grape    Grape   Apple    Apple   Apple   Banana Banana


Is that something you can work with?
 
Upvote 0
Try...

=LOOKUP(9.99999999999999E+307,1/($A$1:$H$1="A"),$A2:$H2)

or if X2 = A, X3 = B, etc. In Y2 enter and copy down:

=LOOKUP(9.99999999999999E+307,1/($A$1:$H$1=$X2),$A2:$H2)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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