Last cell with data
One way, if you need to use it a lot, add the following
function to a module (the row that starts "lngRow ="
should not wrap):
Function RowLastInColumn(argColumn As Integer)
Dim lngRow As Long
On Error Resume Next
lngRow = ActiveSheet.Columns(argColumn).Find(What:="*",
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If IsEmpty(lngRow) Then RowLastInSheet = 0
If Not IsEmpty(lngRow) Then RowLastInColumn = lngRow
End Function
Then call the function and supply the desired column
number like this:
Sub Get_Last_Row_In_Column()
MsgBox RowLastInColumn(2)
End Sub
IF the column is unused, it returns zero.
There are many methods. Hope this helps.
-----Original Message-----
Without looping through all the cells in a column, how
can I determine the last cell that has data in it for a
given column?
.
|