Lee Rabbit
New Member
- Joined
- Apr 30, 2020
- Messages
- 43
- Office Version
- 2010
- Platform
- Windows
Hi,
I am trying to copy a sheet from a closed workbook to the active workbook.
My code below works, however it is copying the sheet and then cell referencing back to the workbook it was copied from.
Is there a way to prevent this happening and just keep the exact same formatting when copied into the active workbook.
Thanks in advance for your help.
Regards, Lee
I am trying to copy a sheet from a closed workbook to the active workbook.
My code below works, however it is copying the sheet and then cell referencing back to the workbook it was copied from.
Is there a way to prevent this happening and just keep the exact same formatting when copied into the active workbook.
Thanks in advance for your help.
Regards, Lee
VBA Code:
Sub Duplicate_Workbook()
Dim ws As Worksheet
Dim wb1 As Workbook
Dim activeWB As Workbook
Set activeWB = Application.ActiveWorkbook
Set wb1 = Workbooks.Open("INVOICES.xlsm")
Set ws = Sheets("INVOICE 1")
ws.Copy After:=activeWB.Sheets("ADMINISTRATION")
wb1.Close SaveChanges:=False
End Sub