+ Reply to Thread
Results 1 to 4 of 4

Change event fails to work

  1. #1
    Mark F
    Guest

    Change event fails to work

    In the change event handler I call a simple function that removes unwanted
    characters from a string value, then returns the string. Simple huh? Well
    I'm using Excel 2000 and this fails to work. Any reason why?

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Target.Value = CheckString(Target.Value)
    Application.EnableEvents = True
    End Sub


    Thanks.
    Mark



  2. #2
    Ron Rosenfeld
    Guest

    Re: Change event fails to work

    On Thu, 10 Nov 2005 01:57:09 GMT, "Mark F" <nonefound@nodomain.com> wrote:

    >In the change event handler I call a simple function that removes unwanted
    >characters from a string value, then returns the string. Simple huh? Well
    >I'm using Excel 2000 and this fails to work. Any reason why?
    >
    >Private Sub Worksheet_Change(ByVal Target As Range)
    >Application.EnableEvents = False
    > Target.Value = CheckString(Target.Value)
    >Application.EnableEvents = True
    >End Sub
    >
    >
    >Thanks.
    >Mark
    >


    Assuming that there is no error in your CheckString function, I would guess
    that in the debugging process you stopped the macro from running with
    Application.EnableEvents still = False.

    It's handy to have a sub to re-enable the events for this scenario.

    Sub foo()
    Application.EnableEvents=True
    end sub


    --ron

  3. #3
    Mark F.
    Guest

    Re: Change event fails to work

    Ron Rosenfeld wrote:
    > On Thu, 10 Nov 2005 01:57:09 GMT, "Mark F" <nonefound@nodomain.com> wrote:
    >
    >
    >>In the change event handler I call a simple function that removes unwanted
    >>characters from a string value, then returns the string. Simple huh? Well
    >>I'm using Excel 2000 and this fails to work. Any reason why?
    >>
    >>Private Sub Worksheet_Change(ByVal Target As Range)
    >>Application.EnableEvents = False
    >> Target.Value = CheckString(Target.Value)
    >>Application.EnableEvents = True
    >>End Sub
    >>
    >>
    >>Thanks.
    >>Mark
    >>

    >
    >
    > Assuming that there is no error in your CheckString function, I would guess
    > that in the debugging process you stopped the macro from running with
    > Application.EnableEvents still = False.
    >
    > It's handy to have a sub to re-enable the events for this scenario.
    >
    > Sub foo()
    > Application.EnableEvents=True
    > end sub
    >
    >
    > --ron


    I used "on error goto" to trap any errors, then I reset events and
    return. Works now, thanks Ron!

  4. #4
    Ron Rosenfeld
    Guest

    Re: Change event fails to work


    >>
    >> Assuming that there is no error in your CheckString function, I would guess
    >> that in the debugging process you stopped the macro from running with
    >> Application.EnableEvents still = False.
    >>
    >> It's handy to have a sub to re-enable the events for this scenario.
    >>
    >> Sub foo()
    >> Application.EnableEvents=True
    >> end sub
    >>
    >>
    >> --ron

    >
    >I used "on error goto" to trap any errors, then I reset events and
    >return. Works now, thanks Ron!


    Happy to help. Glad you have it working now.

    Best wishes,

    --ron

+ 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