Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Temporarily Suspending Worksheet_Change() until other code is run.

Hi all,

I currently have a Worksheet_Change() procedure based upon values
changing in a certain column of my worksheet.

I now wish to add in some additional code that formats and sucks in
data from another sheet, and do not want the Worksheet_Change()
procedure to kick in until the new pre-formating code has been
completed.

Any ideas how I can accomplish this?

Regards,

andym

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Temporarily Suspending Worksheet_Change() until other code is run.

Set the Application .EnableEvents to False to prevent events from
triggering. Then set it back to True. E.g.,

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"andym" wrote in message
oups.com...
Hi all,

I currently have a Worksheet_Change() procedure based upon
values
changing in a certain column of my worksheet.

I now wish to add in some additional code that formats and
sucks in
data from another sheet, and do not want the Worksheet_Change()
procedure to kick in until the new pre-formating code has been
completed.

Any ideas how I can accomplish this?

Regards,

andym



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Temporarily Suspending Worksheet_Change() until other code is run.

Thanks Chip ... worked a charm :)

Regards,

andym

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Temporarily Suspending Worksheet_Change() until other code is run.

Andy

Use

Application.EnableEvents = False

To turn events off and then set it to true at the end of your code. (*OR
anywhere the code may exit, e.g errors, branching, etc)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


"andym" wrote in message
oups.com...
Hi all,

I currently have a Worksheet_Change() procedure based upon values
changing in a certain column of my worksheet.

I now wish to add in some additional code that formats and sucks in
data from another sheet, and do not want the Worksheet_Change()
procedure to kick in until the new pre-formating code has been
completed.

Any ideas how I can accomplish this?

Regards,

andym



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Temporarily Suspending Worksheet_Change() until other code is run.

Two ways -

Just before your routine starts to change cells and trigger the event

On error goto errH
Application.EnableEvents = False

' code

errH:
Application.EnableEvents = True


Or, in a normal module declare a global flag

Public bExit as Boolean

in your event code
If bExit then Exit Sub

Change bExit to True / False at start and when done, also use an error
handler. The bExit method is safer (no risk of not resetting application
settings) but slightly slower.

Regards,
Peter T

"andym" wrote in message
oups.com...
Hi all,

I currently have a Worksheet_Change() procedure based upon values
changing in a certain column of my worksheet.

I now wish to add in some additional code that formats and sucks in
data from another sheet, and do not want the Worksheet_Change()
procedure to kick in until the new pre-formating code has been
completed.

Any ideas how I can accomplish this?

Regards,

andym





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
need help creating a Worksheet_Change code Cajun20th Excel Worksheet Functions 4 May 18th 06 09:12 AM
disappearing worksheet_change VBA code - help! [email protected] Excel Programming 1 December 11th 05 07:20 AM
Worksheet_Change even code will not run retseort[_13_] Excel Programming 3 November 28th 05 10:35 PM
Suspending MAcros Kaval Excel Programming 1 September 27th 04 01:49 AM
suspending-interacting-resuming Ward[_2_] Excel Programming 1 July 8th 04 01:22 PM


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