Intercepting the PASTE command before it happens

mcomp72

Board Regular
Joined
Aug 14, 2016
Messages
202
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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

rlv01

Well-known Member
Joined
May 16, 2017
Messages
1,139
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,147,476
Messages
5,741,351
Members
423,657
Latest member
Medrok2021

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
Top