ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_SheetChange triggered to many times (https://www.excelbanter.com/excel-programming/319686-workbook_sheetchange-triggered-many-times.html)

Devvy D

Workbook_SheetChange triggered to many times
 
Hi there!

When user enters some text in a cell, I use macros to validate.
If there are some incorrect data I want to correct this
programmatically. So I use the SheetChange event.

The problem is that when I correct what the user entered, the event
is fired once again, and then again and again and again... I think you
understand the problem...

How can I work around this problem, is it for example possible to
temporarily disable the event?

Best Regards

L-E

Dave Peterson[_5_]

Workbook_SheetChange triggered to many times
 
Before you write to the cell, tell excel to stop looking for changes.


application.enableevents = false
'your code here
application.enableevents = true

Devvy D wrote:

Hi there!

When user enters some text in a cell, I use macros to validate.
If there are some incorrect data I want to correct this
programmatically. So I use the SheetChange event.

The problem is that when I correct what the user entered, the event
is fired once again, and then again and again and again... I think you
understand the problem...

How can I work around this problem, is it for example possible to
temporarily disable the event?

Best Regards

L-E


--

Dave Peterson

Devvy D

Workbook_SheetChange triggered to many times
 
Thanks a lot, never used that before, but it works like a charm!

Dave Peterson wrote:
Before you write to the cell, tell excel to stop looking for changes.


application.enableevents = false
'your code here
application.enableevents = true

Devvy D wrote:

Hi there!

When user enters some text in a cell, I use macros to validate.
If there are some incorrect data I want to correct this
programmatically. So I use the SheetChange event.

The problem is that when I correct what the user entered, the event
is fired once again, and then again and again and again... I think you
understand the problem...

How can I work around this problem, is it for example possible to
temporarily disable the event?

Best Regards

L-E





All times are GMT +1. The time now is 08:08 AM.

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