How to detect paste event in excel

I need to define a paste command for excel. Is there any work that can tell us when the user clicks the paste in the menu that appears from the left mouse button. I need to complete the procedure if the user clicks the insert menu item. Any help would be appreciated.

Regards, Amit

+6
source share
1 answer

Borrowing from Excel VBA. How to determine if something has been inserted in a worksheet . The Workbook_SheetChange event will fire for any change event on the page, including insertion.

Inside this event, you can check if the last change was nested by looking at the most recent entry in the history of undo lists:

 Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) Dim lastAction As String ' Get the last action performed by user lastAction = Application.CommandBars("Standard").Controls("&Undo").List(1) ' Check if the last action was a paste If Left(lastAction, 5) = "Paste" Then ' Do Stuff Here End If End Sub 
+10
source

Source: https://habr.com/ru/post/925902/


All Articles