+ Reply to Thread
Results 1 to 7 of 7

Event doesn't fire

  1. #1
    Frank Xia
    Guest

    Event doesn't fire

    Hi,
    I am trying a simple worksheet change event as following:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    MsgBox ("ok")
    End sub

    but it does not fire and I can not the msgbox shown up. Is there any
    condition apply to this event?

    Any help appreciated!

  2. #2
    Chip Pearson
    Guest

    Re: Event doesn't fire

    Frank,

    Is the code in the ThisWorkbook code module? It must be in that
    module, not a regular code module, for the code to work. Also,
    ensure that Application.EnableEvents is True. In the VBA Editor,
    press CTRL+G to display the Immediate window, and type the
    following and press Enter

    Application.EnableEvents = True


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Frank Xia" <FrankXia@discussions.microsoft.com> wrote in message
    news:A3B8210F-41D3-4811-9B79-F3F1B2E06FD8@microsoft.com...
    > Hi,
    > I am trying a simple worksheet change event as following:
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > MsgBox ("ok")
    > End sub
    >
    > but it does not fire and I can not the msgbox shown up. Is
    > there any
    > condition apply to this event?
    >
    > Any help appreciated!




  3. #3
    Gary''s Student
    Guest

    RE: Event doesn't fire

    You code works fine, but must be put in worksheet code.

    Right-click any tab
    Select view code
    Enter your code
    --
    Gary's Student


    "Frank Xia" wrote:

    > Hi,
    > I am trying a simple worksheet change event as following:
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > MsgBox ("ok")
    > End sub
    >
    > but it does not fire and I can not the msgbox shown up. Is there any
    > condition apply to this event?
    >
    > Any help appreciated!


  4. #4
    Chip Pearson
    Guest

    Re: Event doesn't fire

    "Chip Pearson" <chip@cpearson.com> wrote in message

    > Is the code in the ThisWorkbook code module?


    This is miswritten. The code must be in a sheet module, not the
    ThisWorkbook module.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Chip Pearson" <chip@cpearson.com> wrote in message
    news:OVmSIRqLGHA.3424@TK2MSFTNGP12.phx.gbl...
    > Frank,
    >
    > Is the code in the ThisWorkbook code module? It must be in that
    > module, not a regular code module, for the code to work. Also,
    > ensure that Application.EnableEvents is True. In the VBA
    > Editor, press CTRL+G to display the Immediate window, and type
    > the following and press Enter
    >
    > Application.EnableEvents = True
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "Frank Xia" <FrankXia@discussions.microsoft.com> wrote in
    > message
    > news:A3B8210F-41D3-4811-9B79-F3F1B2E06FD8@microsoft.com...
    >> Hi,
    >> I am trying a simple worksheet change event as following:
    >>
    >> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    >> MsgBox ("ok")
    >> End sub
    >>
    >> but it does not fire and I can not the msgbox shown up. Is
    >> there any
    >> condition apply to this event?
    >>
    >> Any help appreciated!

    >
    >




  5. #5
    Kevin Vaughn
    Guest

    RE: Event doesn't fire

    Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox "ok"
    End Sub
    Worked for me. I wonder why yours says Excel.range and mine just says range?

    --
    Kevin Vaughn


    "Frank Xia" wrote:

    > Hi,
    > I am trying a simple worksheet change event as following:
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > MsgBox ("ok")
    > End sub
    >
    > but it does not fire and I can not the msgbox shown up. Is there any
    > condition apply to this event?
    >
    > Any help appreciated!


  6. #6
    Frank Xia
    Guest

    RE: Event doesn't fire

    Thanks a lot! This helps and I learned!

    "Gary''s Student" wrote:

    > You code works fine, but must be put in worksheet code.
    >
    > Right-click any tab
    > Select view code
    > Enter your code
    > --
    > Gary's Student
    >
    >
    > "Frank Xia" wrote:
    >
    > > Hi,
    > > I am trying a simple worksheet change event as following:
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > > MsgBox ("ok")
    > > End sub
    > >
    > > but it does not fire and I can not the msgbox shown up. Is there any
    > > condition apply to this event?
    > >
    > > Any help appreciated!


  7. #7
    Frank Xia
    Guest

    Re: Event doesn't fire

    Thank you very much! It helped!

    "Chip Pearson" wrote:

    > Frank,
    >
    > Is the code in the ThisWorkbook code module? It must be in that
    > module, not a regular code module, for the code to work. Also,
    > ensure that Application.EnableEvents is True. In the VBA Editor,
    > press CTRL+G to display the Immediate window, and type the
    > following and press Enter
    >
    > Application.EnableEvents = True
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "Frank Xia" <FrankXia@discussions.microsoft.com> wrote in message
    > news:A3B8210F-41D3-4811-9B79-F3F1B2E06FD8@microsoft.com...
    > > Hi,
    > > I am trying a simple worksheet change event as following:
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > > MsgBox ("ok")
    > > End sub
    > >
    > > but it does not fire and I can not the msgbox shown up. Is
    > > there any
    > > condition apply to this event?
    > >
    > > Any help appreciated!

    >
    >
    >


+ 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