Check if clipboard is empty before pasting


M

Munchkin

I want my macro button to paste what is in the clipboard onto my excel
document, but if the clipboard is empty I want a message to pop up that
states "Your clipboard is empty - retry copying your data." and end the macro.

If there is something in the clipboard it should proceed with pasting it.
I've tried several things but non of them are working.

Cells.Select
ActiveSheet.Paste
 
Ad

Advertisements

R

ron

I want my macro button to paste what is in the clipboard onto my excel
document, but if the clipboard is empty I want a message to pop up that
states "Your clipboard is empty - retry copying your data." and end the macro.

If there is something in the clipboard it should proceed with pasting it. 
I've tried several things but non of them are working.

    Cells.Select
    ActiveSheet.Paste

Try something like the following...Ron

' test to see if the clipboard is empty
If Application.ClipboardFormats(1) = -1 Then
MsgBox "Your clipboard is empty - retry copying your data."
End
Else
Cells.Select
ActiveSheet.Paste
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top