LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Conflicting event procedures launching at the same time

On Nov 7, 7:36*am, Dave Peterson wrote:
You can't change the order of events, but you can turn off all event processing
using:

Application.enableevents = false
'code that would cause other events to fire
application.enableevents = true

And most things you do in code don't have to work on the activesheet or use
selections. *You can refer to the objects directly.

Dim RngToCopy as range
dim DestCell as range

with worksheets("Somesheetnamehere")
* set rngtocopy = .range("a2",.cells(.rows.count,"A").end(xlup))
* set destcell = .range("x99")
end with

application.enableevents = false
rngtocopy.copy _
* destination:=destcell
application.enableevents = true

And you may be able to avoid saving the current location and
"SomeSheetnamehere"'s worksheet_change event.

ps.

Chip Pearson has a workbook that you can download that will show you the order
of events:http://cpearson.com/excel/download.htm
look for EventSeq

And some more links...

Chip Pearson has some instructions on events:http://www.cpearson.com/excel/Events.aspx

David McRitchie has some notes, too:http://www.mvps.org/dmcritchie/excel/event.htm





angelasgwrote:

I have code in sheet 1 that on deactivation looks for an error on
sheet 1 and if it finds one goes to the cell with the error.


At the same time in the code for ThisWorkbook, I've got code that
before saving stores the current cell location then goes to sheet 3
and does some copying and pasting and then goes back to the starting
cell.


I deliberately put an error in Sheet 1 and then hit the save button.
That launched the "before save" code that goes to sheet 3. *That in
turn launched the deactivation code on Sheet 1. *Each code is set to
go to different sheets and do stuff. *They ended up running
simultaneously and doing something I didn't want them to.


Each code by itself works fine, it's just under certain circumstances
that they run at the same time.


I've been using these event procedures for all of two days. *Is there
a way to make them run in a certain order?


Thanks so much in advance.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


I had tried the application.enableevents, but I didn't put them in the
right place. I tried again and it worked fine. Thanks for the help.
 
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
Event procedures: who is calling? Momo[_2_] Excel Programming 2 April 22nd 06 08:12 AM
many similar event procedures natanz[_2_] Excel Programming 1 November 4th 05 02:26 PM
Event Procedures in an Add-In DJB[_10_] Excel Programming 3 September 17th 05 08:11 AM
learning event procedures R.VENKATARAMAN Excel Programming 4 January 21st 05 01:09 PM
Change to excel settings launching an event Jeff Standen Excel Programming 2 August 12th 04 02:00 PM


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