counting # rows in a worksheet
- IF you delete rows/columns it doesn't work ...
UsedRange.Range gets the MAXIMUM RANGE not the REAL range !!!
" wrote:
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
|