+ Reply to Thread
Results 1 to 3 of 3

Disable SelectionChange Event

  1. #1
    BillCPA
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: 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. #3
    BillCPA
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1