Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Copy/Paste doesn't trigger macro

I have a macro that is executed automatically when certain
values change in memory.
These values in memory are derived from cell values which
are read by udf's.
The macro sets the scales and other properties of scatter
charts in the workbook. I have inserted a Debug.Print
instruction for the purpose of testing.
I have also used the Code Cleaner add-in.

Everything is fine when I fill the cells manually, or when I
delete them, or when I copy/paste from an external program
(like notepad). Fine too when I mark and copy text in a cell
and then paste it in the appropriate cell.
But when I copy/paste from within Excel (either from
adjacent cells or from another workbook, and either with
Paste or with Paste Special / Values), the macro code isn't
executed. A Beep instruction inserted in the Change
Properties module isn't executed either.

Can anything be done about this ?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Copy/Paste doesn't trigger macro

Not sure how you have implemented the trigger?

the Private Sub Worksheet_Change event macro will trip on Paste
--
Gary's Student


"Sinus Log" wrote:

I have a macro that is executed automatically when certain
values change in memory.
These values in memory are derived from cell values which
are read by udf's.
The macro sets the scales and other properties of scatter
charts in the workbook. I have inserted a Debug.Print
instruction for the purpose of testing.
I have also used the Code Cleaner add-in.

Everything is fine when I fill the cells manually, or when I
delete them, or when I copy/paste from an external program
(like notepad). Fine too when I mark and copy text in a cell
and then paste it in the appropriate cell.
But when I copy/paste from within Excel (either from
adjacent cells or from another workbook, and either with
Paste or with Paste Special / Values), the macro code isn't
executed. A Beep instruction inserted in the Change
Properties module isn't executed either.

Can anything be done about this ?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Copy/Paste doesn't trigger macro

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Copy/Paste doesn't trigger macro

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
  #5   Report Post  
Posted to microsoft.public.excel.programming
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Copy/Paste doesn't trigger macro

NickHK wrote:
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



You're right about execSetMinMax < 1. I should have tested
it before.

I put debug.print statements at strategic points in the
code, and here is what I found out. When the data is entered
manually, the code runs in the main udf first (where
execSetMinMax is set to 1), then in the Worksheet_Change
module. But when the data is pasted instead, the code runs
in the Worksheet_Change module first, then in the main udf
(and execSetMinMax is set to 1, too late).

This seems to be a bug in Excel, not in my code. Am I right ?
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
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy data into cells until changes trigger new copy mdeanda Excel Programming 2 April 25th 05 01:32 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


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

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

About Us

"It's about Microsoft Excel"