 Hello everyone and welcome back to another tutorial. So in this video, I'm going to be showing you the with feature that we have available in VBA, which predominantly helps save time with our coding, especially when we're making a reference to a particular range, sheet, or any particular object even. And we want to make a number of changes to that. And it allows us to do these changes without having to multiply or refer to this particular range in multiple times. So the best way to do it is to add some code and we'll step straight into it. So sub, and we'll call this using width. And so the first thing we're gonna do is we are going to define our sheet name. So we say we want to work with, say, sheet number one. And let's say we have a multiple number of sheets on here just to make this a bit more applicable. So the first thing we're gonna do is obviously we define our sheet. So we call sheet one as worksheet. And we'll set sheet one equals two sheets. And you guessed it, it's going to be sheet one. Okay, so we've got that. So let's say we now wanted to update a few different values throughout this sheet. So if you wanted to update the value in, obviously cell A1, we would have to do sheet. And I haven't defined my sheet one here correctly, so let's put sheet one. Sheet one dot range A1 dot value equals this A1 there. We'll stick with days of the week here. And then if we now wanted to update, say, another cell within the sheet and we wanted, like, say, row two to be a different value, we'd have to, again, refer to sheet one. So we'd have the sheet one dot range, this time A2 dot value equals Tuesday. And so on and so forth. So we'd have to keep going through and referring to all these different ranges. And let's just do one more, just sort of got people in there, sheet one range A3, and we'll call this one Wednesday. Okay, so if we're to run this code, as expected, you can see it's populated all three of those cells to the days of the week, all those three days of the week, shall I say. So for each one, we've obviously had to keep going back and defining obviously what sheet name is, so the full string of all this information here. Well, we can instead use with, what allows us to get rid of this first part here. So when we use with, what we're gonna do is we literally put with, and okay, with what do we want to do something? So for us, we're gonna say sheet one. And then when we hit enter, you can see that the with has turned blue and it allows us to now add some code. So I'm just gonna tab into this. And then what it allows us to do is just exclude this first reference here because everything we do within this with statement is obviously gonna be within, shall I say, the sheet one reference or sheet one we've got here. So what I can now do is go dot range, open records a one, we'll press there, dot value equals Monday, always go Thursday, and then we can copy this down as well. So we go dot range a two, dot value equals Friday. And lastly, dot range a three, dot value equals Saturday. And then all we need to do at the end here, what's we're trying to do is go end with and that is the end of the statement. So we don't need any of this code here at all. We can delete all that. And you can see it looks a lot more tired here already because we've got the with statement here what says with this sheet one, we want to do all these amendments within that sheet. And obviously once we've done those, we can end the with and this time we'll hit F5 or clear these data first. Let's go F5. And you can see it's now updated for us as well. So with gives us the ability to, well, most importantly, just tidy up our code and make a lot better reference to the values that we need to up or the ranges we need to update with in that particular sheet. A more specific use of using with if we get rid of this could be when we're trying to make updates to a particular cell. So let's say we actually want to change some of the font and the values within one of these cells. We just remove this altogether. So let's say we want to be more specific and we want to be specific with cell A1. So let's say we want to put into here and let's just put a value so we can see that it's changed. So let's say we want to go sheet one dot range A1. So everything we're going to do is going to be obviously a change to this cell here. So the first thing we might want to do is obviously change the value. So we're able to go dot value equals Tuesday. The next thing we might want to do obviously on this cell is maybe change the font color. So we could go dot font dot color equals VB blue. And we're going to too much detail with the different colors, but in short, you can obviously use references like this or you can use the actual color reference code or the palette code. I can't think of what the termination is called, but you may have seen it's like the hex number it starts with like a hashtag and it's a more number of reference or numbering letter reference to the color in particular. You can use either one of those, but for this example, I'll stick with that color of blue here using VB blue. And the last thing we might want to do is go dot font and let's say bold. So you might want to make the text bold equals true. So for that, for the bold aspect, it's either true or false, simple for us. So this is probably a more better example of when we'd want to use width. We want to make all these changes here, but rather than having to keep typing out sheet one dot range a one and then obviously dot value or sheet one range a one dot font color, rather than keep repetitively typing out this first bit we've highlighted here, we can achieve the same and obviously in a lot more tidier manner using the with statement. So if I have to run this now, you can see how the value is updated, the colors changed and the font is now gone to bold. We can also go maybe VB green in our work and then run this and you can see that's now updated. Alternatively, if you wanted to change this as well, we could go to Wednesday, VB let's change it to now red and obviously we'll keep it bold. So you can see that that's a really easy way and sort of nice concise way to reference a particular range and make multiple updates with that without having to repeat yourself in terms of the script. So that video I think was gonna be a bit shorter than normal but obviously the topic we're looking at was quite concise. As always, I appreciate I'll keep repeating myself on this and I refer to when we'll be looking at more advanced processes in the future. I thought it'd be good just to give a dedicated video to this particular topic just so I can obviously one, introduce you to how it works and it also gives you the opportunity to now play around with this and you might even find uses for just this basic functionality already. Obviously it works really well if you've got a lot of data and you may need to make repetitive changes to that particular one cell or maybe even a range of cells that you're wanting to do updates to and VBA is great for automating those repetitive tasks. So if you did enjoy the video, please do give it a like and obviously you appreciate it by myself or is greatly appreciate it by myself as obviously it allows me to see the videos that you are one enjoying and would like to see more of. If you haven't already subscribed, please do subscribe to the channel and also make sure you hit that bell notification button that way you're notified of all of our future videos as soon as they come out. So lastly, thank you very much for watching and we'll see you in the next video.