View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Help Finding the Final Row

Sometimes setting a range to the .usedrange will reset the lastusedcell to what
you think it should be:

Option Explicit
Sub testme()

Dim DummyRng As Range

With Worksheets("sheet1")
Set DummyRng = .UsedRange
MsgBox .UsedRange.Rows(.UsedRange.Rows.Count).Row
End With

End Sub



chris wrote:

Then i guess this will do the trick!

RwCnt = ActiveSheet.UsedRange.Rows.Count
LastRow = ActiveSheet.UsedRange.Offset(x).Resize(1).Row - 1

----- Tom Ogilvy wrote: -----

goto a blank sheet.

enter data in A11, A12, A13

Now run you code:

? Rows(ActiveSheet.UsedRange.Rows.Count).Row
3

Doesn't quite give the correct answer.

You can't assume the usedrange always starts with the first row.
--
Regards,
Tom Ogilvy

"chris" wrote in message
...
try this:
Rows(ActiveSheet.UsedRange.Rows.Count).Row





--

Dave Peterson