View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
SUDHENDRA SUDHENDRA is offline
external usenet poster
 
Posts: 21
Default FINDING LAST ROW OF THE DATA

Thanks
-----Original Message-----
I don't like Usedrange because it will not always give

the last row with data

You can use this funtion also

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious,

_
MatchCase:=False).Row
On Error GoTo 0
End Function

You can use this in your code then for example
Lr = LastRow(Sheets("Sheet2"))





--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"SUDHENDRA" wrote

in message ...
Hi

I have a worksheet with data, the data in each column

is
not continous.

I want to find the last row of the data (the data is in
Column A to Column R) the data is not continus in any

of
the columns.

Can anyone help in writing a VBA code in finding the

last
row of data

thanks in advance



.