Sorry to resurrect an old thread but I was wondering if there was a way to adapt this formula to lookup the second last value in a table. Thank You.
Consider...
[TABLE="width: 319"]
<colgroup><col style="width: 48pt;" width="64"> <col style="width: 53pt; mso-width-source: userset; mso-width-alt: 2531;" width="71"> <col style="width: 48pt;" width="64"> <col style="width: 85pt; mso-width-source: userset; mso-width-alt: 4039;" span="2" width="114"> <tbody>[TR]
[TD="class: xl63, width: 64, bgcolor: transparent"]
ID[/TD]
[TD="class: xl63, width: 71, bgcolor: transparent"]
Value[/TD]
[TD="class: xl64, width: 64, bgcolor: transparent"] [/TD]
[TD="class: xl64, width: 114, bgcolor: transparent"]
ID[/TD]
[TD="class: xl64, width: 114, bgcolor: transparent, align: right"]
1[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
10[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"]
Last Value[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]
40[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
10[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"]
Second Last Value[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]
20[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
3[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
10[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
4[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
10[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
20[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
1[/TD]
[TD="class: xl65, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
3[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
10[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent, align: right"]
1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]
40[/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[TD="class: xl64, bgcolor: transparent"] [/TD]
[/TR]
</tbody>[/TABLE]
E1 houses an ID of interest.
E2, control+shift+enter, not just enter:
Rich (BB code):
=LOOKUP(9.99999999999999E+307,
IF($A$2:$A$9=E1,IF(ISNUMBER($B$2:$B$9),$B$2:$B$9)))
Equivalently, just enter:
Rich (BB code):
=LOOKUP(9.99999999999999E+307,
1/(ISNUMBER($B$2:$B$9)*($A$2:$A$9=E1)),$B$2:$B$9)
E3, control+shift+enter, not just enter:
Rich (BB code):
=LOOKUP(9.99999999999999E+307,
$B$2:INDEX($B$2:$B$9,SMALL(IF($A$2:$A$9=E1,
ROW($A$2:$A$9)-ROW($A$2)+1),COUNTIF($A$2:$A$9,E1)-1)))