ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Looking for formula that selects last value entered in a column? (https://www.excelbanter.com/excel-worksheet-functions/137844-looking-formula-selects-last-value-entered-column.html)

playgolf

Looking for formula that selects last value entered in a column?
 


Bernard Liengme

Looking for formula that selects last value entered in a column?
 
Here is a subroutine that does it:
Sub OneColLastRow()

If Range("A" & Rows.Count).End(xlUp) = "" Then GoTo Finish

'give the last row
myrow = Range("A" & Rows.Count).End(xlUp).Row
Cells(myrow, "A").Select
Exit Sub

Finish:
MsgBox "No formulas or data found"
End Sub

This is adapted from http://vbaexpress.com/forum/showthread.php?t=9774

Need help with VBA? See David McRitchie's site on "getting started" with VBA

http://www.mvps.org/dmcritchie/excel/getstarted.htm

best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"playgolf" wrote in message
...




Billy Liddel

Looking for formula that selects last value entered in a colum
 
Here's a formula as you asked for one

=INDIRECT(ADDRESS(COUNTA(D4:D500)+3,4))

It assumes that you have headers in the first three rows and you want the
last value in column D

Regards

Peter

"Bernard Liengme" wrote:

Here is a subroutine that does it:
Sub OneColLastRow()

If Range("A" & Rows.Count).End(xlUp) = "" Then GoTo Finish

'give the last row
myrow = Range("A" & Rows.Count).End(xlUp).Row
Cells(myrow, "A").Select
Exit Sub

Finish:
MsgBox "No formulas or data found"
End Sub

This is adapted from http://vbaexpress.com/forum/showthread.php?t=9774

Need help with VBA? See David McRitchie's site on "getting started" with VBA

http://www.mvps.org/dmcritchie/excel/getstarted.htm

best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"playgolf" wrote in message
...






All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com