Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default How To Keep Worksheet_Change From Firing?

In MS Access VBA code, I'm creating a spreadsheet and pushing some
WorkSheet_Change code into it.

But as I populate various cells - after adding the code - the event
keeps firing and I'm tripping over chicken-egg situations.

I guess the obvious is not to add the code until everything else is
done.. but I'm wary of yet another chicken-and-egg conundrum.

Is there any way to prevent event code from firing until I've finished
building the spreadsheet?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How To Keep Worksheet_Change From Firing?

Use the line
Application.enableevents = false
to tuirn off events and
Application.enableevents = false
To turn them back on again. It is VERY importtant that you remeber to turn
them back on as this is a persistent application level setting. If you forget
to turn them bakc on then then no events will fire in Excel (until you run
code to turn the events back on).
--
HTH...

Jim Thomlinson


"PeteCresswell" wrote:

In MS Access VBA code, I'm creating a spreadsheet and pushing some
WorkSheet_Change code into it.

But as I populate various cells - after adding the code - the event
keeps firing and I'm tripping over chicken-egg situations.

I guess the obvious is not to add the code until everything else is
done.. but I'm wary of yet another chicken-and-egg conundrum.

Is there any way to prevent event code from firing until I've finished
building the spreadsheet?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How To Keep Worksheet_Change From Firing?

Try this:-

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Exit Sub
'Your code here
End Sub

Mike

"PeteCresswell" wrote:

In MS Access VBA code, I'm creating a spreadsheet and pushing some
WorkSheet_Change code into it.

But as I populate various cells - after adding the code - the event
keeps firing and I'm tripping over chicken-egg situations.

I guess the obvious is not to add the code until everything else is
done.. but I'm wary of yet another chicken-and-egg conundrum.

Is there any way to prevent event code from firing until I've finished
building the spreadsheet?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How To Keep Worksheet_Change From Firing?

Application.enableevents = true OOPs.
To turn them back on again.

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Use the line
Application.enableevents = false
to tuirn off events and
Application.enableevents = false
To turn them back on again. It is VERY importtant that you remeber to turn
them back on as this is a persistent application level setting. If you forget
to turn them bakc on then then no events will fire in Excel (until you run
code to turn the events back on).
--
HTH...

Jim Thomlinson


"PeteCresswell" wrote:

In MS Access VBA code, I'm creating a spreadsheet and pushing some
WorkSheet_Change code into it.

But as I populate various cells - after adding the code - the event
keeps firing and I'm tripping over chicken-egg situations.

I guess the obvious is not to add the code until everything else is
done.. but I'm wary of yet another chicken-and-egg conundrum.

Is there any way to prevent event code from firing until I've finished
building the spreadsheet?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default How To Keep Worksheet_Change From Firing?

Per Jim Thomlinson:
To turn them back on again. It is VERY importtant that you remeber to turn
them back on as this is a persistent application level setting. If you forget
to turn them bakc on then then no events will fire in Excel (until you run
code to turn the events back on).


But only in the context of the currently-running instance of
Excel, right?

i.e. even if the code fails to turn it back on, once they close
the spreadsheet, exit from Excel, and then open some other sheet
they'll be ok...
--
PeteCresswell
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
Macro not firing off Hiran de Silva[_2_] Excel Programming 3 March 12th 06 07:25 PM
Worksheet_Change and Workbook_SheetChange not firing David Jenkins[_2_] Excel Programming 4 September 2nd 04 08:02 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"