I have the following code that will copy sheet1 to a closed workbook. Once the sheet is copied to the Target Workbook, I don't want the code to run there.
The Target WorkBook will periodically have new sheet's added from the Source WorkBook.
Is there either
A) Code that can be added to this sub routine to Disable the code, once the sheet is copied to the closed Workbook, or
B) Something i can add to the Target Workbook directly, to disable all the code there, or
C) Change something in this code to only send the Sheet values to the Target WorkBook
Thanks
The Target WorkBook will periodically have new sheet's added from the Source WorkBook.
Is there either
A) Code that can be added to this sub routine to Disable the code, once the sheet is copied to the closed Workbook, or
B) Something i can add to the Target Workbook directly, to disable all the code there, or
C) Change something in this code to only send the Sheet values to the Target WorkBook
Thanks
VBA Code:
Private Sub CopySheetToClosedWorkbook()
Dim sourceWs As Worksheet
Dim targetWb As Workbook
Dim targetWs As Worksheet
Dim targetWbPath As String
' Set the source worksheet you want to copy from the active workbook
Set sourceWs = Sheet1
' Define the path to the target workbook
targetWbPath = "C:\Closed FireFighter OT Rounds 2024.xlsm"
' Disbales screen updating
Application.ScreenUpdating = False
' Open the target workbook behind the scenes
Set targetWb = Workbooks.Open(targetWbPath)
' Copy the worksheet to the target workbook
sourceWs.Copy After:=targetWb.Sheets(targetWb.Sheets.Count) 'Add something here to only copy the values???
' Save and close the destination workbook
targetWb.Close SaveChanges:=True
' Enables screen updating
Application.ScreenUpdating = True
End Sub