find last row on a worksheet

  • Thread starter Thread starter tracey
  • Start date Start date
T

tracey

I'm sure this is easy but I can't seem to figure it out.
How do get a row count on a worksheet? I wrote code that
will delete blank rows but every spreadsheet is different
and the code keeps running to overflow
 
Hi, Tracey. I do it like this:

Dim LastRow As String
LastRow = Range("AD65536").End(xlUp).Row

Then use LastRow any time I need to identify that row (as in Range("D" &
LastRow).Select or
Loop Until ThisRow > LastRow.

HTH
Ed
 
Ed,

LastRow should be Dim'ed as Integer or Long, not String, as it is a number.

Also, this

LastRow = Range("A" & Rows.Count).End(xlUp).Row

is a little more flexible.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top