Thanks guys for all your posts!
We have now the following solutions:
Function LastRowAddr(C As Long, Optional RowAbsolute As Boolean = True, Optional ColumnAbsolute As Boolean = True) As String
LastRowAddr = Cells(Rows.Count, C).End(xlUp).Address(RowAbsolute, ColumnAbsolute)
End Function
This works great. It delivers a relative address of the last row.
Function SUMDOWN(r As Range) SUMDOWN = WorksheetFunction.Sum(Range(r, Cells(Rows.Count, r.Column).End(xlUp))) End Function
I dont think this will solve the problem. The objective is to create a function for the last row for a definite column.
Function rLastRow(col As Variant, Optional os As Long) As Range Application.Volatile
If Not IsNumeric(col) Then col = Columns(col).Column()
Set rLastRow = Cells(Cells.Rows.Count, col).End(xlUp).Offset(os) End Function
Is this working with the index of the column and the letter (A)?
Or whats the big difference in this kind?
Function LastRow(C As Long) As Range
Set LastRow = Cells(Rows.Count, C).End(xlUp)
End Function
I'm sorry. I not have know, that I searched the range and not exactly the address.
Option Explicit
Public Function LastRowAddress(ColNum As Long) As String
Dim LastCell As Range
Set LastCell = Application.Caller.Parent.Cells(Rows.Count, ColNum).End(xlUp)
LastRowAddress = LastCell.Address(RowAbsolute:=False, ColumnAbsolute:=False)
End Function
Probably this is the best approach, isn't it?
Are there some weak points?
@snb:
The objective was/ is a VBA function. I know, there are different ways with combined excel-functions to solve this problem.
@all:
Which approach would you choose and why?