Find second last value in the column

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Hi,</SPAN></SPAN>

I need a formula that can find second last value in the column either it is number or alphabets.</SPAN></SPAN>

Resulting data...cell </SPAN></SPAN>C1


Book1
ABCDE
1X
2P1
3P1
4P1
51
6X
7X
8X
92
101
11X
12X
131
14
15
16
Sheet11


Thank you in advance</SPAN></SPAN>

Regards,</SPAN>
Kishan</SPAN>
 
Last edited:
Hmm, index 0, eh? I am almost embarrassed to say that in all my time using that shortcut notation, it never occurred to me to try index 0 for the cell above the referenced cell (and I am not usually that rigid in my thinking).

Since there are no blanks in the OP's data, this regular formula should also work...

=INDEX(C:C,COUNTA(C2:C1000))

Thanks Rick for your comments, I really appreciate them.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
In that case, here is another VBA solution for you to consider...
Code:
Sub FindNextToLastInColumn()
  Dim Arr As Variant
  Arr = Range("C1", Cells(Rows.Count, "C").End(xlUp))
  Range("C1") = Arr(UBound(Arr) - 1, 1)
End Sub
By the way, alansidman's approach can be reduced to a one-liner program...
Code:
Sub FindX()
  Range("C1") = Cells(Range("C" & Rows.Count).End(xlUp).Row - 1, "C")
End Sub
Hi Rick, thank you so much both worked fine</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :)
</SPAN></SPAN>
 
Upvote 0
Another VBA solution:

Code:
Sub penultimate()
    [C1] = Range("C" & Rows.Count).End(xlUp)(0)
End Sub
Hi DanteAmor, thank you so much worked fine</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :)
</SPAN></SPAN>
 
Upvote 0
How about a "regular" formula


=LOOKUP(1,1/(C5:C1000<>(LOOKUP(1,1/(C5:C1000<>""),C5:C1000))),C5:C1000)
Hi DanteAmor, thank you this formula return 0</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan
</SPAN></SPAN>
 
Upvote 0
Hmm, index 0, eh? I am almost embarrassed to say that in all my time using that shortcut notation, it never occurred to me to try index 0 for the cell above the referenced cell (and I am not usually that rigid in my thinking).




Since there are no blanks in the OP's data, this regular formula should also work...

=INDEX(C:C,COUNTA(C2:C1000))
Hi Rick, thanks your regular formula return X it is fine!</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :grin:
</SPAN></SPAN>
 
Last edited:
Upvote 0
Hi DanteAmor, thank you this formula return 0

Kind Regards,

Kishan


Yore right, There would be a more complex formula, vote for Rick's formula

=LOOKUP(2,1/((C5:C1000<>(LOOKUP(2,1/(C5:C1000<>""),C5:C1000)) ) * (C5:C1000<>"")),C5:C1000)
 
Upvote 0
Yore right, There would be a more complex formula, vote for Rick's formula

=LOOKUP(2,1/((C5:C1000<>(LOOKUP(2,1/(C5:C1000<>""),C5:C1000)) ) * (C5:C1000<>"")),C5:C1000)
Hi DanteAmor, thanks, yes this one worked fine!</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :)
</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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