View Single Post
  #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