ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Detect copy and paste action (https://www.excelbanter.com/excel-programming/416677-detect-copy-paste-action.html)

Bret Bernever

Detect copy and paste action
 
Hello excel users,

A copy and paste actions invokes a Worksheet_Change event which is fine.

Is it possible to detect that the user performs a copy and paste action?


For example the Worksheet_Change event can look something like this in
pseudocode:

**********
Private Sub Worksheet_Change(ByVal Target As Range)

If User entered data Then
Debug.Print "You entered data in a cell"
ElseIf user performs a copy and paste Then
Debug.Print "You did a copy and paste"
ElseIf User deleted the contents of a cell Then
Debug.Print "You deleted the contents"
End If

end sub
**********

Thanks in advance
Bret

Jim Rech

Detect copy and paste action
 
You cannot tell within Worksheet_Change whether the user pasted an entry in
versus typing it in, as far as I know. You're concerned about your formats
getting blown away?

--
Jim
"Bret Bernever" wrote in message
...
| Hello excel users,
|
| A copy and paste actions invokes a Worksheet_Change event which is fine.
|
| Is it possible to detect that the user performs a copy and paste action?
|
|
| For example the Worksheet_Change event can look something like this in
| pseudocode:
|
| **********
| Private Sub Worksheet_Change(ByVal Target As Range)
|
| If User entered data Then
| Debug.Print "You entered data in a cell"
| ElseIf user performs a copy and paste Then
| Debug.Print "You did a copy and paste"
| ElseIf User deleted the contents of a cell Then
| Debug.Print "You deleted the contents"
| End If
|
| end sub
| **********
|
| Thanks in advance
| Bret


Bret Bernever

Detect copy and paste action
 
In article ,
says...

You cannot tell within Worksheet_Change whether the user pasted an entry in
versus typing it in, as far as I know. You're concerned about your formats
getting blown away?


Well, something like that!

If a user enter some data in a certain range, the worksheet_change event
catches that and triggers a userform (where some additional data can be
entered).
But that isn't necessary (presenting the userform) in case the user does
a copy and paste.

I will look for another approach to tackle this.


All times are GMT +1. The time now is 11:40 AM.

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