View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben's Oak Ben's Oak is offline
external usenet poster
 
Posts: 4
Default Finding the last used cell in a column

I have a workbook that has several worksheets in it, once
of which is suppose to display the total balances from the
other worksheets. There are a total of 4 worksheets.

Worksheets 1 to 3 each have a column that has a running
balance. (I.e. Cell_Value = Previous_Cell + Additions -
Subtractions) These sheets will have an unknown number of
used cells as it will change each time data is entered.

I'm using Excel 97 (can't afford to buy a new version) and
want to select the last used cell in the specified column.
I can't seem to find a built in function, and am having
some trouble getting Excel to find my user-defined
function. (Excel won't recognize it.)

Thus far, I've written:

Public Function Get_Last_Cell_Value( _
ByRef Current_Worksheet As Worksheet, _
ByRef Current_Column As String) As Currency
Dim Total_Count_Of_Column As Integer
Dim Column As Range
Set Column = Current_Worksheet.Columns(,
Current_Column)
Total_Count_Of_Column = Column.Count
Get_Last_Cell_Value = Column.Cells
(Total_Count_Of_Column)
End Function

which should do the trick. The function is stored
in "ThisWorkbook". It's been a while since I've done VBA.
I don't usually program Excel. Am I missing something? Is
there an easier way to do this? I'd rather avoid building
a macro if I can for security reasons.

Help much appreciated.

Ben