Determining if something has been copied

KC Cat

New Member
Joined
Dec 23, 2009
Messages
48
Hello to all,

I have a macro assigned to a toolbar button that will paste a comment. But, it only works if a cell with a comment has actually been copied first. If no copy function has been performed, and the toolbar button is clicked, the following message appears:

Run-time error '1004':
PasteSpecial method of Range class failed


So, is there a way to test first to see if a copy has been performed?

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You should be able to test with :

Code:
If Application.CutCopyMode Then
    'Your Code
End If
 
Upvote 0
Hi there,

Try this (without seeing your code I'm not sure how it looks):

Code:
Sub test()
    On Error Resume Next
    Range("a1").PasteSpecial (xlPasteAll)
    If Err.Number = 1004 Then MsgBox "You have not copied anything!"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top