Thread: End(xlDown)
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default End(xlDown)

lngLastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
Range("b1").Offset(lngLastRow, 0).Select


You might find this interesting... this single line of code will accomplish
the same thing your two lines of code do...

ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Offset(1).Select

The outcome from this part of the statement...

ActiveSheet.Cells(Rows.Count, "B").End(xlUp)

is a Range (actually, a single cell... the last cell in Column B with data
in it), so you can use Offset to move down one row and then select it.

--
Rick (MVP - Excel)


"Normek" wrote in message
...
Thanks Jacob Skaria,

That was very helpful and answered the second part of my question here is
what I came up with:

Sub SelectCell()
lngLastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
Range("b1").Offset(lngLastRow, 0).Select
End Sub

The first part was indirectly answered by smartin in a previous post
today
called
" How to count number of rows with data?"

Here is what I came up with:

Sub CntCells()
ans = Application.WorksheetFunction.CountA(Range(Range(" B2"),
Range("B2").End(xlDown)))
MsgBox ans
End Sub

Thanks to both of you!