excel - Copying Cells from Workbook to Workbook Results in "Subscript Out of Range" -


good day.

i trying write code select cells (left right) "a - m" , (downwards) until last used row.
then, once selected, copy them workbook.

this code tried use:

activeworkbook.worksheets("sheet1").range("a1:m" & lastrow).copy _     workbooks("converter.xlsm").worksheets("sheet1").range("a1").currentregion 

everything else in code works except line.
, result this:

run-time error '9':  subscript out of range 

thanks.

ps. "lastrow" variable used, pulled out of tutorial. that's not personal user-defined variable, not sure if that's vba's documentation.

you mentioned not have calculation lastrow.

  1. always put option explicit @ top of module. forces declare variables , recognize if got coder "built-in" or not.
  2. see this post determining last row in range.
  3. from post, should have calculation such following before line of code ...

    lastrow = sheets("sheet1").range("a" & sheets("sheet1").rows.count).end(xlup).row 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -