 In this video, we're gonna be taking a look at change events. So specifically for this video, we're gonna be looking at how can we execute some code, a runner macro based on or when a workbook opens. So the benefit of this, just to name a couple, could be welcoming people as they open a workbook. It could be obviously to give them instructions, or it could also be anything to update within that sheet. I'm making sure formatting maybe has been reapplied in case someone saved the workbook and had made a change. So obviously when this workbook opens, you may wish to execute some code. That's just gonna do some reformatting or entering dates or any kind of amendments that you want to make sure are enforced every time someone opens this workbook. So it's very simple code. And all we need to do is rather than insert a module, we just need to put this into this workbook. So if you haven't got the coding panel open here, from your Excel sheet, you can either go into the view and then go into macros, or alternatively, as my favorite as well, just go alt, f11, and then it'll bring up this pane on the left-hand side here. And then once you've done that, just double-click this workbook and you're all set to start entering the code. So we've not used private before, but for this one we're going to be using a private subroutine, sorry. So it's exactly the same as previously, it's just got that additional word. So we're gonna just put in here private, and then we're gonna go sub, and we'll do workbook open, and then open and close brackets. And that is the essence of the subroutine we need to do to execute this code. So this is just basically saying, on workbook open, obviously execute all the code that is in this section here before the end sub. We're gonna simply just use a really simple message box, and we're gonna use, again, another sub function we've got available to us in Excel, to display the user's name. So obviously it will look at the Microsoft account for the user openness, and it will take out their username. Just makes it, or gives it a nice little personal touch when someone opens it. So we're gonna simply do end message box, hello, leave a space, and there we go. And environ, open username, close brackets, and symbol, and we'll just do a little exclamation mark at the end there as well. Let's just click away, and you can see it's reformatted for us. So what we can do is let's go down this sub open test, and you can obviously do this as well, or in the Zara scenario now, or this is also a good way of just testing your code before you obviously close it and open it again. If you just run a normal subroutine, then you can see this is the pop-up box we're now expecting to see. So it's just literally gonna say hello, it's gonna get the username, and then do the exclamation mark in there, so you can see for me, it said hello Ben, the exclamation mark. So this is obviously the message box we'll see when we open this workbook. We can just remove this just to avoid any confusion. Once we've got that in there, if we just now save this workbook, we can now close both parts of that. Now if we go into this file I've already got here, and I did skip a step there, obviously you just need to save your workbook, and obviously save it as a macro enabled, so you can see the extension we have at the end here is Excel SM. So this is available to you when you choose the file type you wish to save the file as. So I obviously did that without recording it, but all you need to do is just save that workbook as a file, obviously it was easily accessible. And then when you go to open up that file, double click, you can see that we now get this message box here upon open it, so it says hello Ben for us here. Alternatively, we can just change that to LF11 again, go back to this workbook. Maybe the message box isn't so great, you obviously can get lost or whatever. So all I'm gonna just do is go sheets, open brackets, go sheet one, and then dot range, and go A1, dot value equals, and then I was gonna copy this code out of here, put that there, and we'll just comment this out using the app symbol, obviously not the app symbol, but the same button just without having to push shift. So we can see this time it's gonna go into sheet one and actually paste this value into cell A1. So if you didn't want to use a message box and you wanted to update a value within a cell, this would be the code you use. So once again, we just need to save this file and close it because obviously it's only gonna execute when the file is opened. Double click, and there you can see it's now been updated for us in this cell here. And obviously we can just give it another test. Let's say we changed that to something else like hello Tim, so you can see clearly it is a different value, or let's put goodbye Tim. So we can see it's completely the wrong phrase but saying goodbye in someone else's name. Save that. Now when we open up the workbook, you can see it's been overwritten with our hello Ben quote that we want to show upon opening the workbook. So I hope you enjoyed that short video. If you have any questions about that at all, please just drop me a comment below this video and I will get back to you as soon as I can. If you did enjoy the video as well, please do give the video a like, not only a grade that I appreciate by myself, but obviously it helps that all important YouTube algorithm so more people can find this video. So thank you very much for watching and we'll see you in the next video.