Copy sheet to active workbook, slight issue

Lee Rabbit

New Member
Joined
Apr 30, 2020
Messages
43
Office Version
  1. 2010
Platform
  1. 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

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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Why not set the activeWB to a particular object name e.g Workbooks('Soso") instead of using the Activeworkbook property
 
Upvote 0
Why not set the activeWB to a particular object name e.g Workbooks('Soso") instead of using the Activeworkbook property
This method still links the formulas in the copied sheet to the external spreadsheet it was copied from.

I require the formula to remain as it was originally intended as it feeds off another worksheet within the "copy to" spreadsheet
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top