Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
BillCPA
 
Posts: n/a
Default Disable SelectionChange Event

I have a spreadsheet which has code behind the SelectionChange event. When I
am working on (editing) the worksheet, I want the code active. Later, when I
run a macro to do processing on the worksheet, I want this code deactivated.

Is it possible to use EnableEvents and specify a specific workbook and/or
worksheet and/or event (the SelectionChange event), or does EnableEvents
always apply to the entire application? Is there anyway to disable a
specific event, or is that ever really necessary?

Does EnableEvents affect anything other than workbook and worksheet events?
It seemed to bypass an InputBox sequence when I set it equal to false in one
test.

--
Bill @ UAMS
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Disable SelectionChange Event

Application.enableevents is an application property.

You could turn it off before you do anything in your macro--it'll affect both
workbook, worksheet and application events.

If you want to be more specific, you could set up a global variable:

Public BlkMyEvents as boolean

sub testme()
blkmyevents = true
'do something that would cause a specific event to fire
'select a cell on a worksheet with a _selectionchange procedure
blkmyevents = false
end sub

Then behind that worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if blkmyevents = true then exit sub
'normal code here.
End Sub



BillCPA wrote:

I have a spreadsheet which has code behind the SelectionChange event. When I
am working on (editing) the worksheet, I want the code active. Later, when I
run a macro to do processing on the worksheet, I want this code deactivated.

Is it possible to use EnableEvents and specify a specific workbook and/or
worksheet and/or event (the SelectionChange event), or does EnableEvents
always apply to the entire application? Is there anyway to disable a
specific event, or is that ever really necessary?

Does EnableEvents affect anything other than workbook and worksheet events?
It seemed to bypass an InputBox sequence when I set it equal to false in one
test.

--
Bill @ UAMS


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
BillCPA
 
Posts: n/a
Default Disable SelectionChange Event

I put in the stuff for using a specific variable. Works well - thanks for
your help!

--
Bill @ UAMS


"Dave Peterson" wrote:

Application.enableevents is an application property.

You could turn it off before you do anything in your macro--it'll affect both
workbook, worksheet and application events.

If you want to be more specific, you could set up a global variable:

Public BlkMyEvents as boolean

sub testme()
blkmyevents = true
'do something that would cause a specific event to fire
'select a cell on a worksheet with a _selectionchange procedure
blkmyevents = false
end sub

Then behind that worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if blkmyevents = true then exit sub
'normal code here.
End Sub



BillCPA wrote:

I have a spreadsheet which has code behind the SelectionChange event. When I
am working on (editing) the worksheet, I want the code active. Later, when I
run a macro to do processing on the worksheet, I want this code deactivated.

Is it possible to use EnableEvents and specify a specific workbook and/or
worksheet and/or event (the SelectionChange event), or does EnableEvents
always apply to the entire application? Is there anyway to disable a
specific event, or is that ever really necessary?

Does EnableEvents affect anything other than workbook and worksheet events?
It seemed to bypass an InputBox sequence when I set it equal to false in one
test.

--
Bill @ UAMS


--

Dave Peterson

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
Unable to Start Excel Event ID 2001 Melih Excel Discussion (Misc queries) 3 January 22nd 06 11:18 PM
Using excel to manage event - ANY input deeply appreciated! :-) ojbelboe Excel Discussion (Misc queries) 3 January 18th 06 10:21 PM
Same event, multiple sheets? Robert Smith Excel Discussion (Misc queries) 1 December 24th 04 11:36 AM
Excel Automation SelectionChange event cpotts Excel Discussion (Misc queries) 1 December 20th 04 05:15 PM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


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