Finding Last value

roanscar

New Member
Joined
Oct 19, 2006
Messages
3
I know I have seen this on the boards before but now can't find it.

Here is a sample of what the data will look like for columns a & b:

A B
Red 25
Red 30
Red 14
Blue 25
Blue 13


I am trying to get a formula so that it will return the last value entered in column B based on the value in column A[/i]
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
If your data is sorted as in your example:

=INDEX(B:B,MATCH("Red",A:A,FALSE)+COUNTIF(A:A,"Red")-1)
 

roanscar

New Member
Joined
Oct 19, 2006
Messages
3
Thank you sir!

Out of curiousity, what would the formula be if the reds and blues were intermingled?
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try eg:

=INDEX(B1:B5,MAX(IF(A1:A5="Red",ROW(INDIRECT("1:"&ROW(A5))),0)))

which must be confirmed with Ctrl+Shift+Enter, not just Enter. If correctly entered Excel will surround this array formula with curly braces {}.
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
=INDEX(B1:B5,MAX(IF(A1:A5="Red",ROW(A1:A5)-ROW(A1)+1)))

which needs to be confirmed with control+shift+enter, not just with enter.

A different idiom is:

=LOOKUP(2,1/(A1:A5="Red"),B1:B5)

which needs just enter.
 

Forum statistics

Threads
1,141,011
Messages
5,703,726
Members
421,311
Latest member
tanujath

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
Top