Copy to destination file

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
754
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I am trying to create a macro that pulls data in from another workbook.
Currently I can get the macro to open the file and copy the data, but i am being thick and missing something when trying to copy it to my open workbook.
The line in red below is where it isnt working. I am missing something that specifies the open workbook

Sorry, I am being a bit thick this morning.

Thanks
Gavin


Rich (BB code):
Application.ScreenUpdating = False
Dim src_wbk As Workbook
Dim Dest_Wbk As Workbook
    
    Set Dest_Wbk = ActiveWorkbook
    Sheets("Team Update").Select
    Range("A2:AW8060").ClearContents
    
    MyManager = Worksheets("Info").Range("J4").Value
    
    If MyManager = "MGR1" Then
            Set mybook = Workbooks.Open("MGR1.xlsx", Password:="mgr1l") 'Work
                End If
    If MyManager = "MGR2" Then
            Set mybook = Workbooks.Open("MGR2.xlsx", Password:="mgr2") 'Work
                End If
    If MyManager = "MGR3" Then
            Set mybook = Workbooks.Open("mgr3.xlsx", Password:="mgr3") 'Work
                End If   
    
    Set src_wbk = mybook 'manager file open
    ActiveWorkbook.Sheets("Quality").Select
    ActiveSheet.Range("$A$3:$AW$50000").Copy
    
    'copy to Quality
    Set Dest_Wbk = Workbooks("Quality 2013 v2.xlsm")
   Sheets("Team Update").Select
    Range("A2").Select
    ActiveSheet.Paste
   
   'src_wbk.Close
    src_wbk.Saved = False
    src_wbk.Close
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Good Morning,

I have changed the code around and can close the file before copying the data across, but i get a message "There is a large amount of Data". Pres "Yes" to save it on the clipboard. I understand src_wbk.Close closes the file etc.. but can i get the VB to automatically click "Yes"

Cheers
Gavin

Code:
src_wbk.Close
src_wbk.Saved = False

'copy to Quality
Set Dest_Wbk = Workbooks("Quality 2013 v2.xlsm")
Sheets("Team Update").Select
Range("A2").Select
ActiveSheet.Paste
 
Upvote 0
Application.DisplayAlerts = False suppresses the warning, then Application.DisplayAlerts = True restores warnings.
 
Upvote 0
src_wbk.Closesrc_wbk.Saved = False'copy to QualitySet Dest_Wbk = Workbooks("Quality 2013 v2.xlsm")Sheets("Team Update").SelectRange("A2").SelectActiveSheet.PasteApplication.CutCopyMode = FalseTry this....</PRE>
 
Upvote 0
Does the workbook you're trying to copy the data from have more sheets you don't need? If not why not just add the sheets from the workbook you want to get the data from?
 
Upvote 0

Forum statistics

Threads
1,206,756
Messages
6,074,758
Members
446,084
Latest member
WalmitAal

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