Thread: End(xlDown)
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default End(xlDown)

Try the other way (xlUp). To get the last row filled in Column A

lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

If this post helps click Yes
---------------
Jacob Skaria


"Normek" wrote:

Hi Fellow Excel users,
Has anyone come across the following problem before and do they have an
answer?

End(xlDown) is a useful shortcut method, however in a macro similar to this
below, if the cells below contains only one record or no records, then the
count is 1048575 in Excel 2007 or 50000 in excel 2003.

Sub CntCells()
ans = Range(Range("A1"), Range("A1").End(xlDown)).Count
MsgBox ans
End Sub

Similarly
Range("A1").End(xlDown).Offset(1, 0).Select
fails because Range("A1").End(xlDown).Select will select the last row

Has anyone any thoughts or alternatives?

Thanks in advance