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
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:
gt;
gt; I have a spreadsheet which has code behind the SelectionChange event. When I
gt; am working on (editing) the worksheet, I want the code active. Later, when I
gt; run a macro to do processing on the worksheet, I want this code deactivated.
gt;
gt; Is it possible to use EnableEvents and specify a specific workbook and/or
gt; worksheet and/or event (the SelectionChange event), or does EnableEvents
gt; always apply to the entire application? Is there anyway to disable a
gt; specific event, or is that ever really necessary?
gt;
gt; Does EnableEvents affect anything other than workbook and worksheet events?
gt; It seemed to bypass an InputBox sequence when I set it equal to false in one
gt; test.
gt;
gt; --
gt; Bill @ UAMS
--
Dave Peterson
I put in the stuff for using a specific variable. Works well - thanks for
your help!
--
Bill @ UAMSquot;Dave Petersonquot; wrote:
gt; Application.enableevents is an application property.
gt;
gt; You could turn it off before you do anything in your macro--it'll affect both
gt; workbook, worksheet and application events.
gt;
gt; If you want to be more specific, you could set up a global variable:
gt;
gt; Public BlkMyEvents as boolean
gt;
gt; sub testme()
gt; blkmyevents = true
gt; 'do something that would cause a specific event to fire
gt; 'select a cell on a worksheet with a _selectionchange procedure
gt; blkmyevents = false
gt; end sub
gt;
gt; Then behind that worksheet:
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt; if blkmyevents = true then exit sub
gt; 'normal code here.
gt; End Sub
gt;
gt;
gt;
gt; BillCPA wrote:
gt; gt;
gt; gt; I have a spreadsheet which has code behind the SelectionChange event. When I
gt; gt; am working on (editing) the worksheet, I want the code active. Later, when I
gt; gt; run a macro to do processing on the worksheet, I want this code deactivated.
gt; gt;
gt; gt; Is it possible to use EnableEvents and specify a specific workbook and/or
gt; gt; worksheet and/or event (the SelectionChange event), or does EnableEvents
gt; gt; always apply to the entire application? Is there anyway to disable a
gt; gt; specific event, or is that ever really necessary?
gt; gt;
gt; gt; Does EnableEvents affect anything other than workbook and worksheet events?
gt; gt; It seemed to bypass an InputBox sequence when I set it equal to false in one
gt; gt; test.
gt; gt;
gt; gt; --
gt; gt; Bill @ UAMS
gt;
gt; --
gt;
gt; Dave Peterson
gt;
- Jul 16 Mon 2007 20:38
Disable SelectionChange Event
close
全站熱搜
留言列表
發表留言