Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event triggered by paste
I found the following on Microsoft's page regarding the OnEntry
Property and Change Event: The event does not occur if the user click Cut or Paste on the Edit menu or if another procedure changes the contents of a cell. So how does one go about triggering an event when data is pasted into a worksheet? Thanks, John |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event triggered by paste
John
This should be sort of possible using a Worksheet_Change() event and checking for Application.CutCopyMode, which indicates if something is on the clipboard There are some issues with this, but this simple code demonstrates the principal Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, Range("A1")) Is Nothing Then If Application.CutCopyMode Then MsgBox "User is pasting" Exit Sub End If MsgBox "User is not pasting" End If End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England www.nickhodge.co.uk HIS wrote in message ups.com... I found the following on Microsoft's page regarding the OnEntry Property and Change Event: The event does not occur if the user click Cut or Paste on the Edit menu or if another procedure changes the contents of a cell. So how does one go about triggering an event when data is pasted into a worksheet? Thanks, John |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event triggered by paste
Actually, the event is triggered when a single cell is pasted. It is
not triggered if the number of cells is more than one. Still searching... John |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Event triggered by paste
John
Sorry, the application.Intersect is restricting it... I always restrict the cells on which the change event operates. This will work on any cells Private Sub Worksheet_Change(ByVal Target As Range) If Application.CutCopyMode Then MsgBox "User is pasting" Exit Sub End If MsgBox "User is not pasting" End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England www.nickhodge.co.uk HIS wrote in message ups.com... Actually, the event is triggered when a single cell is pasted. It is not triggered if the number of cells is more than one. Still searching... John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change event triggered by a named range | Excel Programming | |||
Macro triggered by an event | Excel Discussion (Misc queries) | |||
Worksheet_Change Event triggered off specific cell | Excel Programming | |||
Is this an Excel workbook event triggered AFTER saving | Excel Programming | |||
Event triggered by Hiding/Unhiding columns? | Excel Programming |