range select question

  • Thread starter Thread starter Nic
  • Start date Start date
N

Nic

My data colums are fixed, A-J
However row changes on daily basis.

Range("A1:J11").Select
Selection.Copy

How do I replace the J11 with J variable to represent the last row,
effectively selecting the entire active range.
 
Are you trying to select within a macro or manually?

If manually, consider clicking in your cell block and pressing Ctrl+Shift+8
(or Ctrl+A in Excel 2003).

If you are doing it in a macro, try activating a cell in your range that
will always be in the range and selecting its CurrentRegion.
Ex:

range("A1").currentregion.copy

Or, you could modify it, so that you just have to click in the Range before
running the macro:

selection.currentregion.copy

Note that it isn't necessary to actually Select the range to copy it.

tj
 
you do NOT need to select to copy. After getting lastrow the one liner will
do to copy your range to sheet2!a1

lastrow=cells(rows.count,"a").end(xlup).row
range("a1:j"&lastrow).copy sheets("sheet2").range("a1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top