ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Variable Range paste last row + 1 (https://www.excelbanter.com/excel-programming/412786-select-variable-range-paste-last-row-1-a.html)

SteveT

Select Variable Range paste last row + 1
 
Hello,

Looking for macro solution to perform following

1) Copy Variable Range (A2:C?) from source.xls
2) Paste Range to last row + 1 destination.xls

There are many posts concerning but none are performing task needed.
Ron de Bruin's solution in posting "copy & paste macro" has come closest but
I continually get compile error.

Thanks in advance for any assistance.

BR,

Steven




Dave Peterson

Select Variable Range paste last row + 1
 
Dim RngToCopy as range
dim DestCell as range

with workbooks("source.xls").worksheets("somesheetnameh ere")
set rngtocopy = .range("A2:C" & .cells(.rows.count,"A").end(xlup).row)
end with

with workbooks("Destination.xls").worksheets("someother sheetnamehere")
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell



The code depends on the last used cell in column A for both ranges.

SteveT wrote:

Hello,

Looking for macro solution to perform following

1) Copy Variable Range (A2:C?) from source.xls
2) Paste Range to last row + 1 destination.xls

There are many posts concerning but none are performing task needed.
Ron de Bruin's solution in posting "copy & paste macro" has come closest but
I continually get compile error.

Thanks in advance for any assistance.

BR,

Steven


--

Dave Peterson


All times are GMT +1. The time now is 05:41 PM.

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