Excel VBA Command to Clear the Clipboard

When using copy and paste in a macro it is a good idea to clear the clipboard at the end of the macro. If you don’t, the user could use paste to paste the last thing you had copied in the macro.

Luckily it is easy to clear the clipboard. It’s a one line command

Application.CutCopyMode=False

Usually you place this command near the end of your macro. You can also include it after each paste in your code to make sure the clipboard is cleared between each copy and paste.

If you use error handling code you would place the command with all the code to run when the macro finishes.

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

2 thoughts on “Excel VBA Command to Clear the Clipboard

  1. That was really the solution I was looking for! Every now and then a message requesting me to manage the clipboard pops up while running my macro in excel, and just by adding this command after the “paste” command lines, I can stop worrying about whether the clipboard is full or not!
    Thanks a lot!