ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Change event fails to work (https://www.excelbanter.com/excel-worksheet-functions/54704-change-event-fails-work.html)

Mark F

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



Ron Rosenfeld

Change event fails to work
 
On Thu, 10 Nov 2005 01:57:09 GMT, "Mark F" 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

Mark F.

Change event fails to work
 
Ron Rosenfeld wrote:
On Thu, 10 Nov 2005 01:57:09 GMT, "Mark F" 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!

Ron Rosenfeld

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


All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com