sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
Good morning,
I have this code that will copy a worksheet from a source workbook to an existing worksheet my destination workbook. Looking for some assistance on making this same code work to copy several worksheets from the source workbook to existing worksheets in my destination workbook without having to close the source workbook each time between copying each worksheet over to the destination workbook.
This is the code that I have now for copying just the one worksheet over:
I have this code that will copy a worksheet from a source workbook to an existing worksheet my destination workbook. Looking for some assistance on making this same code work to copy several worksheets from the source workbook to existing worksheets in my destination workbook without having to close the source workbook each time between copying each worksheet over to the destination workbook.
This is the code that I have now for copying just the one worksheet over:
VBA Code:
Sub Update_AllWSData()
Dim WB As Workbook
Dim DestSht As Worksheet
Dim SourceSht As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set DestSht = ThisWorkbook.Worksheets("WIP")
Set WB = Workbooks.Open(Filename:="G:\CompanyName\Manufacturing Detail Schedule1.xlsx") 'Selected File full path
Set SourceSht = WB.Worksheets("WIP")
lastRow = SourceSht.Cells(Rows.Count, "B").End(xlUp).Row
SourceSht.Range("B1:V" & lastRow).Copy
WB.Close
Worksheets("WIP").Select
DestSht.Range("A1").Select
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
DisplayAsIcon:=False, NoHTMLFormatting:=True
Range("A2").Select
Worksheets("Jobs").Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub