ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba; copy row, paste at offset (https://www.excelbanter.com/excel-programming/408539-vba%3B-copy-row-paste-offset.html)

md[_2_]

vba; copy row, paste at offset
 
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.

JLGWhiz

vba; copy row, paste at offset
 
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.

"md" wrote:

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.


JLGWhiz

vba; copy row, paste at offset
 
To copy only the data in a row you can use something like this:

lstCol = ActiveSheet.SpecialCells(xlCellTypeLastCell).Colum n
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.

"md" wrote:

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.



All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com