Excel Macro - Copy / Paste Sheets from one workbook to another

mldaigle1
mldaigle1 used Ask the Experts™
on
Hello Experts,

I'm sure this is very simple, but need your expertise to do that macro.   I need to copy data from workbookA.SheetIN_Data and paste it into workbookB.SheetIN_Data, starting at cell A2 (Row 1 are my headers in workbookB).

I have a total of 6 sheets that need the data to be transfert from one book to the other (SheetIN_Data,SheetCH_Data, SheetWO_O, SheetWO_B, SheetWO_H, Sheet_PR).

Can you help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Best and most efficient is you to post both workbooks and will take it from there.
gowflow
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Sub CopySheetData()

Dim wbDest As Workbook
Dim wbSource As Workbook

Set wbSource = ActiveWorkbook
Set wbDest = Workbooks("workbookB")

wbSource.Sheets("SheetIN_Data").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetIN_Data").Range("A2")


End Sub

Open in new window

Roy CoxGroup Finance Manager

Commented:
Is the data from all sheets being consloidated into one sheet in the other workbook?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Older than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Ignore my first answer.
Sub CopySheetData()

Dim wbDest As Workbook
Dim wbSource As Workbook

Set wbSource = ActiveWorkbook
Set wbDest = Workbooks("workbookB")
With wbSource
    .Sheets("SheetIN_Data").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetIN_Data").Range("A2")
    .Sheets("SheetCH_Data").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetCH_Data").Range("A2")
    .Sheets("SheetWO_O").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetWO_O").Range("A2")
    .Sheets("SheetWO_B").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetWO_B").Range("A2")
    .Sheets("SheetWO_H").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("SheetWO_H").Range("A2")
    .Sheets("Sheet_PR").UsedRange.Cells.Offset(1, 0).Copy Destination:=wbDest.Sheets("Sheet_PR").Range("A2")
End With

End Sub

Open in new window

Author

Commented:
Hi Martin,

This work just fine!!

thanks,

xxx

/mld
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial