View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Copy/Paste doesn't trigger macro

The event will not fire for a paste if any of the following are true
- Events disabled
- Macros disabled
- WS is protected and you are trying to paste into locked cells

Otherwise maybe your SetMinMax is not running because execSetMinMax < 1 ?

NickHK

"Sinus Log" wrote in message
...
Sinus Log wrote:
Gary''s Student wrote:
Not sure how you have implemented the trigger?

the Private Sub Worksheet_Change event macro will trip on Paste


The macro's name is SetMinMax.
The function MiseEnMem sets the value of the variable execSetMinMax to 0
or 1.
The code in the Change module:

Option Explicit
Private Sub Worksheet_Change(ByVal Region As Range)

Dim a As Long, b As Variant, critique As Long

If Not Intersect(Region, Range("a1:a1")) Is Nothing Then
critique = 1
enMemOptim_A = 0: enMemOptim_B = 0: enMemOptim_C = 0: enMemOptim_D =

0
enMemAxeComp = 0: enMemAxesCompos = 0
End If
'(More regions...)

If critique = 1 Then
b = MiseEnMem("")
Application.Calculate
End If

If execSetMinMax = 1 Then SetMinMax
execSetMinMax = 0
End Sub


I have created a small workbook to mimick the macro and
functions of my project, and there's no problem at all with
Paste. Now if I had a general idea of what is causing the
problem, I might be able to correct it. Could it be:
- too much load on the memory
- too many cells intercepted by the Sub Worksheet_Change
- the duration of the calculations
- path too long: worksheet - Worksheet_Change - udf -
Worksheet_Change - macro SetMinMax