Function to find last value in a column
The best method for finding the last cell with data in a column on the active
sheet is:
lastRow = Cells(Rows.Count, "AD").End(xlUp).Row
You can substitute the column number without quotes where the "AD" appears.
It works either way. This does a bottoms up search of the column to find the
absolute last cell since the xlDown would stop if there is a blank cell
between the starting cell and the last cell. To set a variable to the range
for that cell:
myVar = Range("AD" & lastRow)
"Andyjim" wrote:
Hi-
I submitted this post without entering anything on the subject line. So I
am re-entering this. I need to create a function that can be placed in a
cell that will display the last number in another column. Below are some
attempts, but no success. Thanks for your help!
Andy
Function LastValue(lastno As Variant)
Dim sysexpcol As Range
Set sysexpcol = Range(ad16, ad56)
Set lastno = sysexpcol(Cells.Value.xlDown)
End Function
Function lastvalueincolumn(foundcell As Variant)
With Worksheets("analysis").Range("ad:ad")
Set foundcell = .Cells.Find.Value.xlDown
End With
End Function
|