ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Finding Last value in a column (https://www.excelbanter.com/excel-discussion-misc-queries/181972-finding-last-value-column.html)

Chris Miller

Finding Last value in a column
 
Currently I am using the following Macro to find the last/bottom value of a
column:

Sheets("Daily").Activate
n = Cells(Rows.Count, "l").End(xlUp).Row
Cells(n, "l").Copy Sheets("Data").Range("D8")

I was wondering if it is possibe to use a function instead if a macro to
find the last vlaue in a column?

Thnaiks

Gary''s Student

Finding Last value in a column
 
Perhaps:

Function lastvalueincolumn(r As Range) As Variant
lastvalueincolumn = ""
cl = r.Column
If IsEmpty(Cells(Rows.Count, cl).Value) Then
n = Cells(Rows.Count, cl).End(xlUp).Row
lastvalueincolumn = Cells(n, cl).Value
Else
lastvalueincolumn = Cells(Rows.Count, cl).Value
End If
End Function


used as:

=lastvalueincolumn(A:A)
--
Gary''s Student - gsnu200776


"chris miller" wrote:

Currently I am using the following Macro to find the last/bottom value of a
column:

Sheets("Daily").Activate
n = Cells(Rows.Count, "l").End(xlUp).Row
Cells(n, "l").Copy Sheets("Data").Range("D8")

I was wondering if it is possibe to use a function instead if a macro to
find the last vlaue in a column?

Thnaiks


Gord Dibben

Finding Last value in a column
 
=LOOKUP(1E+100,A:A)


Gord Dibben MS Excel MVP

On Mon, 31 Mar 2008 17:54:25 -0700, chris miller
wrote:

Currently I am using the following Macro to find the last/bottom value of a
column:

Sheets("Daily").Activate
n = Cells(Rows.Count, "l").End(xlUp).Row
Cells(n, "l").Copy Sheets("Data").Range("D8")

I was wondering if it is possibe to use a function instead if a macro to
find the last vlaue in a column?

Thnaiks




All times are GMT +1. The time now is 04:50 AM.

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