 Welcome to another video. In this video, we're going to continue our look at change events. And this video in particular, we're going to look at when one of the cell values in the sheet changes. So it could be any sheet, but for us it's just sheet number one, as that's the only sheet we have at the moment. When any of these cell values change, we want a macro to execute or execute some VBA code. So that could be anything from a message box, it could be formatting, it could be anything that you wish. But ultimately it's all about triggering a macro to start based on a change event that happens within this sheet. So the first thing we're going to do is obviously, well not the first thing we're going to do, we're going to just jump straight into it. So for this to work, we need to make sure that we type our code into the relevant sheet. So for us we only have sheet number one, but there we go. We can see we've got sheet one here and we just need to double click to make sure we're into that sheet. And then once here, we can now start typing. So we're going to go private sub and we're going to put workbook, or no sorry, work sheet. And then we're going to go underscore change, open brackets. So that's the first part. So it's a private sub and this is obviously worksheet change. So obviously when there's a change happening within this worksheet. And we also, within these brackets, we've not done this before, but we need to start typing some extra pieces of information in here as well. So we're going to be yval target as range. And so basically what they're saying is obviously our target is going to be a range. And by default, it just means the whole of this sheet. So in essence, what we can do is we could say that this is not our code entirely, but this is the entire change event we require to be able to execute a code based on a change. So if I was going to here and they say we put message box and do hello to something very basic there. If we come into our sheet, you can see as we navigate around the sheet, nothing happens. But if we were to go into a cell and change the value, so put the value of M could be anything and hit enter. You can see that we now get that pop up box. So obviously what's happened is a value has actually changed. Sorry, let me explain that better. So because something has changed within this sheet upon it being changed obviously our macro executes. And the only thing we have in that macro at the moment is this message box to say hello. So that will happen every time a change is made in this worksheet. And just to be more specific, it will only happen when a change is made like as into a cells value. So if I was to come into here and change the color, so make it yellow, obviously you can see that nothing's happened. If however I was going into there and I typed a word such as hello and hit enter, you can see that's what now actually triggers that macro to execute. Also it's worth noting, even if you don't make a change to the cell, but say like you double click. So as you may know, you don't need to click into a cell, you could just literally slip the cell and then make a type to change the contents or you can double click into a cell if you want to get the cursor. If I was to now move or navigate out of this cell, you can see that it's again executed this pop up box. And that's because even though no physical change has happened in the sheet, you've actually gone into, shall we say, or call it edit mode by having the cursor in there. So obviously that is a nothing itself to trigger the code to execute. So, and also it's worth noting if I delete these columns, again, another change event is triggered because I've deleted those columns, so we do okay. So that's how you can do it as a basic change and that might be relevant if you have maybe some secure information in the sheet or just something that you want to bring people's attention to that they're not allowed to make a change in that sheet. And you could even do some more advanced features with this. I guess you could probably lock the spreadsheet if you really want this to be changed but you could obviously enforce logic in here. So if statements based on if there's a change happening to help add some policing and control to your worksheet. So the possibility are quite endless with this but in short, this first part would just now look at how you can obviously execute the code based on any change to that sheet. So let's get a bit more detailed now. So we might want to say that we only want to run this code if something happened or there's a change made in column A. In order to do that, we just need to make a bit more update our code and add some more lines. And we're gonna do that through adding an if statement. So to do that, we're gonna go if not intersect, open brackets, and then now we need to define our target. So our target was obviously defined at all given up in the top here. So we're saying our target as a range. So our target comma range, and let's say we're gonna call this column A. So we literally just need to do the two A's there. Close brackets because we've got two brackets to close. So if that change is nothing, then execute our code else and if. So you can go back into here and now we'll do our message box. Column A has changed. So something a bit more informative there, but you can see again, very simple. So if we come over back into our sheet, if we now go and change a value and I'm just putting random letters and numbers throughout the sheet, you can see if I do any of that in column B onwards, nothing is happening. Although if I go into column A and now put a letter, you can see that it's now gonna execute that code. So column A has changed. So that's how you can obviously have your code executed based on the change, but only if that change occurs we're in a defined range. And we don't have to be the whole of column A, we could change this to maybe just A1 or row one to row five of column A. So as you can see, if we go to row six and make any changes here, nothing is gonna update. But if we were to go into row five or above, you can see that that will now execute the code. And again, if we delete these columns here, nothing will happen if I delete column A, then yeah, a change has happened because some of those values were contained or our range was contained within that column. So we've covered off some very basic ways of using these two change types. So we've got the change type based on that sheet as a whole and obviously defining of a specific range within there to execute the code as well. In future videos, we'll be looking at more detailed ways or sort of say more advanced ways of why you might want to use or where this type of code comes in real benefit to give a taste there when using user forms. So if you want to get those videos and make sure you don't miss them, please do subscribe to the channel, hit that bell notification button as well. That way you will be notified as soon as new videos get uploaded onto our channel. Again, if you did enjoy the video, please do give the video a like as it would be greatly appreciated by myself. And lastly, thank you very much for watching once again and we'll see you in the next video.