VBA Macro Copy and Paste to another workbooks without links

slohman

Board Regular
Joined
Mar 31, 2012
Messages
110
This is the macro I'm using with 2 problems so far

Code:
Sub Move_Master_EstimatingSheet()
Dim SDrv   As String
Dim DDrv   As String
Dim Sfname As String
Dim Dfname As String
Dim wkbSrc As Workbook
Dim wkbDst As Workbook


    Application.DisplayAlerts = False
    Application.EnableEvents = False
    
    SetAttr "c:\Sue\ESTIMATING SHEET.xlsm", vbNormal

   
   SDrv = "c:\Sue\"
   Sfname = "Supplier Master Price List.xl??"
    

   DDrv = "c:\Sue\"
   Dfname = "ESTIMATING SHEET.xlsm"

    Set wkbSrc = Workbooks.Open(SDrv & Sfname)
   
    
    Set wkbDst = Workbooks.Open(DDrv & Dfname)
        
    Sheets("Master").Visible = True
    wkbDst.Sheets("Master").Delete   'Delete List sheet from Dest
    wkbSrc.Sheets("Master").Copy After:=wkbDst.Sheets("Rubber")
    
    ActiveSheet.Protect Password:="???", DrawingObjects:=True, Contents:=True, Scenarios:=True
    
    Sheets("Opt1").Select

    Range("A1:X1500").Select
            
    Selection.Replace What:="#REF!$C:$L", REPLACEMENT:="Master!$C:$L", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False
    
    Selection.Replace What:="#REF!$S:$AB", REPLACEMENT:="Master!$S:$AB", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False
        
    Selection.Replace What:="#REF!", REPLACEMENT:="Master!$C:$L", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False
        
    Worksheets("Opt1").Activate
    Range("$K2").Select
    
    Sheets("Master").Visible = False
    
    Application.DisplayAlerts = True
   
    ActiveWorkbook.Close SaveChanges:=True
       
    SetAttr "c:\Sue\.xlsm", vbReadOnly

End Sub

Firstly the macro is deleting and replacing the worksheet in the destination workbook so I have to do find and replace any formula's I have on other worksheets that refer to the Master worksheet.

Secondly if it just pasted values and formats would that fix the links problems I seem to get when I open up the destination workbook after it has been saved as I have to answer update links continue every time?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Copy and entire worksheet to another workbook that has the same worksheet name in it, but when I copy it, I have noticed it comes in with links, then when I reopen the destination workbook it ask if I want to update links. I don't want links I just want an easy copy and paste function.
 
Upvote 0
Perhaps turning off update link warnings

Code:
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
    Set wkbSrc = Workbooks.Open(SDrv & Sfname)
    
    Set wkbDst = Workbooks.Open(DDrv & Dfname)
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
 
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,006
Members
452,542
Latest member
Bricklin

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