How can I avoid the clipboard message box when copying large amounts of data in Excel?
I would modify the macro. Turn off alerts when the macro starts and turn them back on when the macro is done. i.e. Application.DisplayAlerts = False
The problem with Application.DisplayAlerts = False
is that it may hide an alert you need to see.
Use Application.CutCopyMode = False
after the paste, which removes the link to the large range from the clipboard.
I agree with Jon Peltier, "The problem with Application.DisplayAlerts = False
is that it may hide an alert you need to see."
Plus you have to remember to set Application.DisplayAlerts = True
after you're done, so that's 3 lines of code for each paste
AND if your program interrupts BEFORE Application.DisplayAlerts = True
you'll have unknowingly turned off alerts until you quit Excel.
I tested his suggestion Application.CutCopyMode = False
after the paste, it works fine. Here is an example in someSpreadsheet.xls
:
Workbooks.OpenText Filename:="someDirectory\someFile.txt", _
DataType:=xlDelimited, TextQualifier:=xlNone, _
Tab:=True
Cells.Select
Selection.Copy
Windows("someSpreadsheet.xls").Activate
ActiveSheet.Paste
Application.CutCopyMode = 0
Windows("someFile.txt").Activate
ActiveWorkbook.Close
I found this MS document regarding this. It looks like you can use a few different programatic solutions in your macro to resolve this. It just depends on what exactly you are copying to clipboard.KB # 287392