ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need value of last number in a column (https://www.excelbanter.com/excel-programming/404801-need-value-last-number-column.html)

Ron Smith

Need value of last number in a column
 
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.
--
Ron Smith in Round Rock

Mark Ivey

Need value of last number in a column
 
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)



"Ron Smith" wrote in message
...
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.
--
Ron Smith in Round Rock




All times are GMT +1. The time now is 02:54 PM.

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