Hey guys, welcome back. So in this video we're going to discuss how we can disable events and how we can re enable them again, okay, so if we disable the events, anything that is triggered as a result of an event is not going to be triggered okay? So any code that is triggered for example, by double clicking a cell will not be triggered, okay, events are disabled, this feature in Excel will be disabled and we will see why we're going to need to use that. Okay, but first of all to disable an event you can write application dot enable events equals false, okay? This is how you can disable events and to re enable them again you can write application enable events equals true Okay, so if you run the first line of code here for the disabled events Sub procedure, if you run that, events will be disabled.
So for example on this before double click sheet here, where we actually explained it before double click event and we said that if we double click on any of these names, it will be transferred to cell three, this will not happen, okay? Because events are disabled. So any code that is triggered as a result of a certain action will be disabled. Okay, so to re enable the events again and re enable that feature, you can just run the application, enable events equals true so if you run that, and we just double click here you can see are the names are being transferred to cell l three, okay, so the events are now working. And of course you can include these lines are lines of code in any procedure that you write even event procedures and we're going to see why these are useful. Okay, if at any point you just want to check if the events are enabled or disabled, not enable them or disable them, but just check.
Are they enabled or disabled at the moment at this moment? Are they enabled or disabled, you can go to your immediate window This is a nice little trick, okay, so you can go to your immediate window here. And if it's not enabled, you can click on view here and then click on immediate window to view it. Okay and write a question mark and then application dot enable events. Okay? Do not write equals true or false or anything just write this question mark application dot enable events and press enter.
It will just tell you is it true or false. So if it's true, then they are enabled. If it's false, then events are disabled. So this is a nice little trick that you can use to check if at a certain moment events are enabled or disabled. And in future videos, we're going to see why enabling and disabling events are useful. Okay, so thanks for watching this video.
I'll see you on the next one.