Finding Last value in a column

C

chris miller

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
 
G

Gary''s Student

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top