Intercepting the PASTE command before it happens

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
I have a macro-enabled workbook that is used on both Windows & Mac. There are some columns that are "locked" because they have formulas in them, and I don't allow the user to unlock them, or to unprotect the sheets. Sometimes a user will try to paste data into some cells on a sheet, and one of the cells is locked. They get the standard message from Excel that says they can't do that since the cell is on a protected sheet. What I'm wondering if, is there some way I could intercept the PASTE command before it actually attempts to do the paste, and have it check the range that they are trying to paste into? If they are trying to paste into a cell that is locked, I would like it to display a message box with a custom message, explaining exactly which cell/column that cannot paste into.

I have Googled around for a solution, but haven't had any luck. It may not be possible to intercept the PASTE command, but if it is, I figure someone here would probably know.

One thing to remember is I would need to solution work on Mac as well as Windows. So any solution that uses Windows API's wouldn't work in this case.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I'm probably not telling you anything you did not already suspect, but I am skeptical that this can be done. And if it could be done, it would almost certainly involve some Win API trickery that you said was out of bounds because you need to target both Win and Mac platforms.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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