Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default enableevents in event codes

I hope this is not a dumb question!

in some event codes I see in the beginning the code statement
application.enableevents=false
and then at the end
application.enableevents=true

are these two statements (I understnad if one is there the otehr should be
there) necessary and why?
Thanks and regards.
mine excel 2002(windows xp)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default enableevents in event codes

For example, if you have code inside a WorkSheetChange event that changes
the worksheet then it would trigger the WorkSheetChange code again:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveCell = ActiveCell + 1
End Sub

So my question is, why doesn't this cause an endless loop? It stops when
activecell value hits 227.

Doug


"R..VENKATARAMAN" wrote in message
...
I hope this is not a dumb question!

in some event codes I see in the beginning the code statement
application.enableevents=false
and then at the end
application.enableevents=true

are these two statements (I understnad if one is there the otehr should be
there) necessary and why?
Thanks and regards.
mine excel 2002(windows xp)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default enableevents in event codes


In most case yes - it stops the macro retriggering itself

In the following example the macro will run everytime any cell is
changed even when the macro changes a1

Private Sub Worksheet_Change(ByVal Target As Range)
range("a1").value=target.address & " Changed"
End Sub


In the follwing example the macro changing a1 does not trigger a fresh
update to a1

Private Sub Worksheet_Change(ByVal Target As Range)
application.enableevents=false
range("a1").value=target.address & " Changed"
application.enableevents=true
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=536685

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
Application.EnableEvents DCPan Excel Worksheet Functions 3 October 18th 08 05:46 AM
need programming help with nested event codes timber Excel Programming 1 April 6th 06 05:33 PM
Linking worksheet event codes Mr. G. Excel Worksheet Functions 7 July 15th 05 06:15 PM
Application.EnableEvents = true, but no event fires Wexler Excel Programming 0 October 19th 04 06:08 PM


All times are GMT +1. The time now is 04:43 AM.

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"