[Excel VBA] How to Suppress “Large Amount of Information on the Clipboard” Warning

Environment

  • Edition: Windows 10 Pro
  • Version: 20H2

Background

When I tried to close a file using VBA, the following message appeared:

“There is a large amount of information on the Clipboard. Do you want to be able to paste this information into another program later?”

Today, I learned how to handle this issue.

Solution: Use “Application.CutCopyMode = False”

To resolve this, you need to add the following line of code:

Application.CutCopyMode = False

Cause

The message appears because the workbook is being closed while cells are still in “Copy Mode” (indicated by the dotted border or “marching ants” around the selected cells).

Therefore, canceling the Copy Mode before closing the file solves the problem.

Implementation

Insert the code immediately after your paste operation.

' Example Code
Sub CopyAndPasteSample()
    
    ' 1. Copy data
    Range("A1:B10").Copy
    
    ' 2. Paste data
    Range("D1").PasteSpecial xlPasteValues
    
    ' 3. Cancel Copy Mode (Clear Clipboard)
    Application.CutCopyMode = False
    
    ' Now you can close the workbook without the warning
    ' ActiveWorkbook.Close

End Sub

Summary

  • The warning occurs if you close Excel while the dotted border from a copy operation is still active.
  • By writing Application.CutCopyMode = False after pasting, you can clear the clipboard and prevent the message from appearing.


よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

私が勉強したこと、実践したこと、してることを書いているブログです。
主に資産運用について書いていたのですが、
最近はプログラミングに興味があるので、今はそればっかりです。

目次