Large amount of information copied to clipboard message box.

Tucker92

Board Regular
Joined
Jun 7, 2018
Messages
53
I am trying to copy a large amount of information from one spread sheet to another but i need to close the first spreadsheet down before i paste the information When i do this i get that annoying message box pop up and have to press yes everytime. Is there anyway i can do it using my vba.

I tried to use the Application.DisplayAlerts = False and true but they only hide it and then i cannot paste my information afterwards.
And i cant clear my clipboard until i have pasted it.

Thank you
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This code worked for me to copy data from a Book2.xlsx, close the workbook then paste it to the workbook holding the code:

Code:
    Windows("Book2.xlsx").Activate
    Range("A1:H50").Copy
    Application.DisplayAlerts = False
    ActiveWindow.Close
    Range("G12").Select
    ActiveSheet.Paste

With Excel 2016 & Windows 10, code in a standard module
 
Upvote 0
Another way would be to use an intermediate temporary workbook
Something like this
Code:
Sub CopyLarge()
    Application.ScreenUpdating = False
    Const path1 = "C:\Test\CopyFromThis.xlsx", path2 = "C:\Test\PasteToThis.xlsx"
    Dim wb As Workbook, temp As Workbook, rng As Range
[I][COLOR=#800080]'open first workbook and set range to be copied[/COLOR][/I]
    Set wb = Workbooks.Open(path1)
    Set rng = wb.Sheets("Sheetname").Cells(1).CurrentRegion
[I][COLOR=#800080]'add temporary workbook \ copy to temp \ close first workbook[/COLOR][/I]
    Set temp = Workbooks.Add
    With temp.Sheets(1)
        rng.Copy .Cells(1)
        Application.CutCopyMode = False
        Set rng = .Cells(1).CurrentRegion
    End With
    wb.Close True
[I][COLOR=#800080]'open second workbook\ copy from Temp \ close temp[/COLOR][/I]
    Set wb = Workbooks.Open(path2)
    With wb.Sheets("PasteSheet").Range("A1")
        rng.Copy .Cells(1)
        Application.CutCopyMode = False
    End With
    temp.Close False
    wb.Save
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,452
Messages
6,124,915
Members
449,195
Latest member
Stevenciu

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