Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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
 
Perfect. Thanks

Norman Jones said:
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
 

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