Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 334
Default Unwanted code execution

When executing the following code:

Do
If MyCellMe.Value = A1NmeMe Then
Sheets(TagNmeMe).Select
Range("B4").Select
If MyCellMe.Value = "" Then
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.EnableEvents = True
Range("A4").Select
If MyCellMe.Value = "" Then
Set MyCellMe = MyCellMe.Offset(1, 0)
If MyCellMe.Address = EndCelMe.Address Then
MsgBox "Needs to insert new rows"
Exit Do
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Loop

This code gets executed, which is on a seperate workseet:

Private Sub WorkSheet_Change(ByVal Target As Range)
vArr = Array("AMXD", "BAMB", "BAVR", "BAVS", "CVG", "CITI", "DISC", "WAMU")

' commeted out code
'
'
'
'
'
ErTherapy:
Application.EnableEvents = True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 269
Default Unwanted code execution

The line Application.EnableEvents=True is allowing change events to occur.

The Worksheet_Change Module you show is activated when the worksheet changes.

I am guessing that Application.EnableEvents=False is used somewhere else is
the code to turn off events. So you likely need the =True statement
somewhere to trun events back on.

Try moving the Application.EnableEvents=True statement to after the Loop line.
--
If this helps, please remember to click yes.


"Rick" wrote:

When executing the following code:

Do
If MyCellMe.Value = A1NmeMe Then
Sheets(TagNmeMe).Select
Range("B4").Select
If MyCellMe.Value = "" Then
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.EnableEvents = True
Range("A4").Select
If MyCellMe.Value = "" Then
Set MyCellMe = MyCellMe.Offset(1, 0)
If MyCellMe.Address = EndCelMe.Address Then
MsgBox "Needs to insert new rows"
Exit Do
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Loop

This code gets executed, which is on a seperate workseet:

Private Sub WorkSheet_Change(ByVal Target As Range)
vArr = Array("AMXD", "BAMB", "BAVR", "BAVS", "CVG", "CITI", "DISC", "WAMU")

' commeted out code
'
'
'
'
'
ErTherapy:
Application.EnableEvents = True
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Unwanted code execution

If you trace the code at what point does the event code fire. In short which
line of code is the last to execute before the worksheet change code fires.
Event code like taht can be tought to debug as you get into thech change
fires this event. That event code makes changes firing other event code and
....

In short it is hard to help you on this one. You need to trace with break
points and the F8 key to see what is generating events.
--
HTH...

Jim Thomlinson


"Rick" wrote:

When executing the following code:

Do
If MyCellMe.Value = A1NmeMe Then
Sheets(TagNmeMe).Select
Range("B4").Select
If MyCellMe.Value = "" Then
ActiveCell.EntireRow.Copy
ActiveCell.Offset(1, 0).Activate
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Application.EnableEvents = True
Range("A4").Select
If MyCellMe.Value = "" Then
Set MyCellMe = MyCellMe.Offset(1, 0)
If MyCellMe.Address = EndCelMe.Address Then
MsgBox "Needs to insert new rows"
Exit Do
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Else
Set MyCellMe = MyCellMe.Offset(1, 0)
End If
Loop

This code gets executed, which is on a seperate workseet:

Private Sub WorkSheet_Change(ByVal Target As Range)
vArr = Array("AMXD", "BAMB", "BAVR", "BAVS", "CVG", "CITI", "DISC", "WAMU")

' commeted out code
'
'
'
'
'
ErTherapy:
Application.EnableEvents = True
End Sub


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
Code Execution Message canderson Excel Discussion (Misc queries) 1 October 9th 09 04:28 PM
Code execution has been interrupted LAF Excel Discussion (Misc queries) 2 February 21st 08 03:03 PM
Code Execution has been interupted Rich Excel Discussion (Misc queries) 2 May 10th 05 12:52 PM
code execution has been interrupted François Excel Discussion (Misc queries) 1 February 18th 05 11:06 PM


All times are GMT +1. The time now is 05:12 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"