View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default counting # rows in a worksheet

Tonhao,

Why not simply use:

Public Function lastRowNbr(Optional colRef As Variant) As Long

If IsMissing(colRef) Then
'Give last row of the longest column
lastRow = ActiveSheet.UsedRange.Rows.Count
Else
'Give last row of the identified column
lastRow = Cells(Rows.Count, colRef).End(xlUp).Row
End If

End Function


Brian M