vba; copy row, paste at offset

  • Thread starter Thread starter md
  • Start date Start date
M

md

I have a row copied to the clipboard, and I want to paste it into
sheetB at rowR, colC.

I can do the paste if I select the entire row, but that's now what I
want. Thank you.
 
If you copy an entire row, you have to paste an entire row. You can't put
more into less. If you want to paste into less space, you need to reduce the
amount you copy to the size (or smaller) of the space you want to paste into.
 
To copy only the data in a row you can use something like this:

lstCol = ActiveSheet.SpecialCells(xlCellTypeLastCell).Column
Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, lstCol).Copy

If you are using a variable to identify the cursor location, then substitute
that for the ActiveCell. That will give you a range that is only as long as
the last cell with data in it. Then you can paste it in a range less than a
full row length.
 

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