View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas[_4_] Gary Keramidas[_4_] is offline
external usenet poster
 
Posts: 226
Default excel 2010 question regarding determining the last row

i've seen usedrange be problematic at times. some cleaning of the worksheet
was necessary to get that function to work.

--


Gary Keramidas
Excel 2003


"Rich Locus" wrote in message
...
Hello:

I would use what I would consider the "Industry Standard". It is in John
Walkenbach's book on VBA Excel Programming:

Public Sub Tester()
Dim intNumberOfRowsInWorksheet As Long
intNumberOfRowsInWorksheet = ActiveSheet.UsedRange.Rows.Count
intNumberOfRowsInWorksheet = intNumberOfRowsInWorksheet +
ActiveSheet.UsedRange.Row - 1
MsgBox ("Number Of Rows in Worksheet = " & intNumberOfRowsInWorksheet)
End Sub

Hope that helps.
--
Rich Locus
Logicwurks, LLC


"Gary Keramidas" wrote:

never really used 2007, so i'm wondering if you've seen this behavior in
2010, or 2007, for that matter.

typically, in 2003, ws3.Cells(Rows.Count, "A").End(xlUp).Row, would
return
the last row

but, in 2010, i frequently get debugs on this line when opening a 2003
workbook in compatibility mode.

so, i've resorted to change the code to this and it seems to resolve the
issue:
ws3.Cells(ws3.Rows.Count, "A").End(xlUp).Row

seems excel is sometimes thinking it has a million rows, when in fact
there
are only 65000, so it debugs. seems to happen when i open another
workbook
with code.

anyone seen this or have a better way?


--


Gary Keramidas
Excel 2003


.