ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if clipboard is empty before pasting (https://www.excelbanter.com/excel-programming/439171-check-if-clipboard-empty-before-pasting.html)

munchkin

Check if clipboard is empty before pasting
 
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

ron

Check if clipboard is empty before pasting
 
On Feb 3, 12:28*pm, Munchkin
wrote:
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


All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com