Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change event triggered by a named range Sean Excel Programming 4 August 1st 05 03:01 AM
Macro triggered by an event AussieAVguy Excel Discussion (Misc queries) 2 June 16th 05 05:51 AM
Worksheet_Change Event triggered off specific cell ExcelMonkey[_142_] Excel Programming 2 June 7th 04 03:33 AM
Is this an Excel workbook event triggered AFTER saving Lee Drage[_2_] Excel Programming 3 January 29th 04 08:11 AM
Event triggered by Hiding/Unhiding columns? Jerry W. Lewis Excel Programming 1 July 23rd 03 09:17 AM


All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"