ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros (https://www.excelbanter.com/excel-programming/311882-macros.html)

burg

Macros
 
Hello,

How do I make a macro that copies data from one spreadsheet and then pastes
it into another spreadsheet, BUT does not paste over the top of the existing
data and pastes a row lower?

Thanks

Norman Jones

Macros
 
Hi Burg,

The following copies A1:D6 on Sheet1 to a range on Sheet2 starting at the
next empty cell in column A.

Sub Demo()
Dim srcRng As Range, destRng As Range

Set srcRng = Sheets("Sheet1").Range("A1:D6")
Set destRng = Sheets("Sheet2"). _
Cells(Rows.Count, "A").End(xlUp)(2)

srcRng.Copy destRng
End Sub

---
Regards,
Norman



"burg" wrote in message
...
Hello,

How do I make a macro that copies data from one spreadsheet and then
pastes
it into another spreadsheet, BUT does not paste over the top of the
existing
data and pastes a row lower?

Thanks




burg

Macros
 
Thanks Norman,

Just wondering how you specify a file path. I want to paste the data into
another spreadsheet. It is in the same folder so does this make it easier?

Thanks

Norman Jones

Macros
 
Hi Burg,

Try something like:

Sub Demo02()
Dim srcRng As Range, destRng As Range
Dim WB1 As Workbook, WB2 As Workbook

Set WB1 = Workbooks("MySourceBook.xls")
Set WB2 = Workbooks("MyDestinationBook.xls")
Set srcRng = WB1.Sheets("Sheet1").Range("A1:D6")
Set destRng = WB2.Sheets("Sheet1"). _
Cells(Rows.Count, "A").End(xlUp)(2)

srcRng.Copy destRng
End Sub


---
Regards,
Norman



"burg" wrote in message
...
Thanks Norman,

Just wondering how you specify a file path. I want to paste the data into
another spreadsheet. It is in the same folder so does this make it easier?

Thanks




burg

Macros
 
Perfect. Thanks

"Norman Jones" wrote:

Hi Burg,

Try something like:

Sub Demo02()
Dim srcRng As Range, destRng As Range
Dim WB1 As Workbook, WB2 As Workbook

Set WB1 = Workbooks("MySourceBook.xls")
Set WB2 = Workbooks("MyDestinationBook.xls")
Set srcRng = WB1.Sheets("Sheet1").Range("A1:D6")
Set destRng = WB2.Sheets("Sheet1"). _
Cells(Rows.Count, "A").End(xlUp)(2)

srcRng.Copy destRng
End Sub


---
Regards,
Norman



"burg" wrote in message
...
Thanks Norman,

Just wondering how you specify a file path. I want to paste the data into
another spreadsheet. It is in the same folder so does this make it easier?

Thanks






All times are GMT +1. The time now is 09:54 PM.

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