Need to get value of last number in a column
Not sure what you mean. Range("A55") is column A, row 55. Range("C55") is
column C, row 55. These can also be written as Cells(55, 1) and Cells(55, 3)
respectively. To assign them to a variable: myVar = Cells(55, 3) would make
myVar equal "$C$55". To find the last cell in a column that contains data
you can use: ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
That code snippet will cause VBA to look from the last row on the sheet in
column 3 (or C) until it finds a cell with data. That will be the last entry
in that column, so to use it in code you assign a variable like:
lastRow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
Then you can identify the cell as either Range("C" & lastRow) or
Cells(lastRow, 3)
"Ron Smith" wrote:
I submitted this an hour ago, but it was never posted -- and so I apologize
if it shows up twice. I have a column(s) of portfolio values, updated daily
or weekly. I want to find the last number entered in the column so that I
can compare it to the beginning of the year portfolio value and calculate my
losses for the year. I find I can use the ROW function to find the number of
the last Row that I entered, but I can't seem to use this number in a Cell
reference:
i.e. +C=ROW(A55) to reference Cell C55 doesn't work
Is there a way to make this function work in a Cell reference, or is there
another function that would give me this information or is there a better way
to do this.
Thanks.
--
Ron Smith in Round Rock
|