ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to disable tempory an automatic Worksheet_Change Event (https://www.excelbanter.com/excel-programming/419742-how-disable-tempory-automatic-worksheet_change-event.html)

[email protected]

How to disable tempory an automatic Worksheet_Change Event
 
Hoi,

I'm using a macro to copy data from file-1 to file-2.
In file-2 (which is not my file) an automatic ChangeEvent is build in
by another person on such a way that when I copy data to a specific
datafield I get an automatic popup with a question.
It's not allowed for me to change this code, but............ I don't
want that pop-up when I'm copying data into it. Is there a way I can
disable that code when I'm copying.

Something like:
'disable code for AutoEvent.....
'copy data
'enable code for AutoEvent....

below the code which I found in that file-2 as I mentioned.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedRange As Range
Set ChangedRange = Range("I25:I33")
If Union(Target, ChangedRange).Address = ChangedRange.Address Then
CheckResult '=run another macro
End If
End Sub

regards,
Johan

Barb Reinhardt

How to disable tempory an automatic Worksheet_Change Event
 
Sure, use

Application.EnableEvents = FALSE

to disable event handling and

Application.EnableEvents = TRUE

to enable event handling.

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



" wrote:

Hoi,

I'm using a macro to copy data from file-1 to file-2.
In file-2 (which is not my file) an automatic ChangeEvent is build in
by another person on such a way that when I copy data to a specific
datafield I get an automatic popup with a question.
It's not allowed for me to change this code, but............ I don't
want that pop-up when I'm copying data into it. Is there a way I can
disable that code when I'm copying.

Something like:
'disable code for AutoEvent.....
'copy data
'enable code for AutoEvent....

below the code which I found in that file-2 as I mentioned.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedRange As Range
Set ChangedRange = Range("I25:I33")
If Union(Target, ChangedRange).Address = ChangedRange.Address Then
CheckResult '=run another macro
End If
End Sub

regards,
Johan


Dave Peterson

How to disable tempory an automatic Worksheet_Change Event
 
Maybe...

Application.enableevents = false
'copy data
application.enableevents = true

wrote:

Hoi,

I'm using a macro to copy data from file-1 to file-2.
In file-2 (which is not my file) an automatic ChangeEvent is build in
by another person on such a way that when I copy data to a specific
datafield I get an automatic popup with a question.
It's not allowed for me to change this code, but............ I don't
want that pop-up when I'm copying data into it. Is there a way I can
disable that code when I'm copying.

Something like:
'disable code for AutoEvent.....
'copy data
'enable code for AutoEvent....

below the code which I found in that file-2 as I mentioned.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedRange As Range
Set ChangedRange = Range("I25:I33")
If Union(Target, ChangedRange).Address = ChangedRange.Address Then
CheckResult '=run another macro
End If
End Sub

regards,
Johan


--

Dave Peterson

Chip Pearson

How to disable tempory an automatic Worksheet_Change Event
 
Joban,

You can disable events with the Application.EnableEvents setting.
E.g.,


Application.EnableEvents = False
' your code here
Application.EnableEvents = True

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Sun, 9 Nov 2008 04:06:19 -0800 (PST), wrote:

Hoi,

I'm using a macro to copy data from file-1 to file-2.
In file-2 (which is not my file) an automatic ChangeEvent is build in
by another person on such a way that when I copy data to a specific
datafield I get an automatic popup with a question.
It's not allowed for me to change this code, but............ I don't
want that pop-up when I'm copying data into it. Is there a way I can
disable that code when I'm copying.

Something like:
'disable code for AutoEvent.....
'copy data
'enable code for AutoEvent....

below the code which I found in that file-2 as I mentioned.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedRange As Range
Set ChangedRange = Range("I25:I33")
If Union(Target, ChangedRange).Address = ChangedRange.Address Then
CheckResult '=run another macro
End If
End Sub

regards,
Johan



All times are GMT +1. The time now is 02:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com