Need value of last number in a column

R

Ron Smith

I have a column of numbers (stock prices) that I am updating daily. I want
to use the last value I entered in the column to calculate my losses (current
price - fixed beginning stock price). I can get the Row number with the ROW
function, but am unsuccessful when trying to use this number in a Cell
reference:
i.e. +C=ROW(A55) -- where C is the column and =ROW(A55) will return 55
(contents of Cell 55 being what I am after).
Is there a way I can get this Cell reference to work or is there another
function or method I can use to determine the last value in a column.
 
M

Mark Ivey

Give this snippet a go...

Assign it to a variable: myCellValue = Cells(Rows.Count,
3).End(xlUp).Value

Then you can utilize "myCellValue" somewhere else in your code.

If you are looking for a user defined function, take a look at the following
from http://www.mvps.org/dmcritchie/excel/lastcell.htm

' Apply this function to a new module in your workbook
Function LastInColumn(rng As Range) As Variant
LastInColumn = Cells(Rows.Count, rng(1).Column).End(xlUp).Value
End Function

Then you can reference it on your worksheet with the following function
call:

=LastInColumn(C:C)
 

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