View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Mark Ivey[_2_] Mark Ivey[_2_] is offline
external usenet poster
 
Posts: 171
Default Unable to mark the range in VB and get application error- WHY

Rick,

He was actually wanting to select the used range from A5 to E and last row
in the used range. I really don't think he was going to select A5 before
running the code and I also think this is actually something to work in
conjunction with some of the stuff he had posted yesterday.

Either way... thanks for your input. It is always appreciated.

Mark

"Rick Rothstein (MVP - VB)" wrote in
message ...
While I recognize the OP has finished with this thread, I thought I would
add my comment for the archives at least. Considering the OP said he had
A5 set as the selected cell; assuming selecting a starting cell before
running the macro is how the OP always proceeds, then your Range-approach
solution can be shortened down even further to this one-liner...

Range(ActiveCell, ActiveCell.End(xlDown)).Select

Rick


"Mark Ivey" wrote in message
...
Consider this....

If I fully understand your request, give this snippet a go...


Mark



LastRow = Range("A5").End(xlDown).ROW

Range("A5:E" & LastRow).Select









"CAPTGNVR" wrote in message
...
DEAR ALL

Active cell is A5. I need to select the range from 5th row to the last
populated cell which is obtained from xldown.row to 5 columns to the
right.

Public Sub LASTTROW()
LASTROW = ActiveCell.End(xlDown).Row
ActiveCell.Range(Cells(0, 0), Cells(LASTROW, 5)).Select
End Sub

What is wrong in this code to get run time error 1004-
'application-defined
or object defined error'.

or sugest VB to mark from the active cell to last populated row and 5
columns to the right.

pls help-captgnvr