In week one of the course, I went through just a very basic introduction to using VBA subroutines. And as I mentioned before, it's never too early to start thinking about how you can Implement VBA in your Excel's spreadsheets. So in this screencast, I'm going to talk to you about how you can create user-defined functions in VBA. And if you like what you see here and you're more interested, you can always take more of the Coursera courses that are available. I teach a specialization of three courses focused all on VBA with Excel. So maybe every single day you find yourself calculating the volume of a cone, the formula here is, for the volume of a cone pi r squared times h divided by 3. And you kind of get sick of typing in that formula, so you want to create your own custom function called cone volume that you'll be able to put in a radius and a height. So I'm going to show you how we can custom-make a user-defined function using VBA. The first thing, you want to go ahead and make sure on the File tab > Options > Customize Ribbon. Make sure you have the Developer tab checked and then you click OK and now you should have the Developer tab up here. Go ahead and go over to Visual Basic, we didn't do this in week one, but I'm going to show you how we can insert something known as a module. So don't put your code on this thing that pops up, instead, you're going to go Insert > Module. So make sure you Insert > Module and this is where we're going to put the code. If you don't have Option Explicit up there, that's fine, for now, you can always just go ahead and type that in if you'd like, although it is optional. So I'm going to type in the following. I'm going to type in CONE VOL and then I've typed in parentheses the arguments to this function. So this function is going to have two arguments, I'm declaring them as something known as a data type. So I'm declaring them as Double, you'll learn more about that if you're interested in taking some Excel and VBA courses, but basically it just means that it has double precision and it's stored as a real number. I'm also going to declare or dim this variable pi and that's also going to be a real number. And I'm going to borrow Excel's worksheet function, its pi function, so I can just type in pi equals WorksheetFunction.pi and now, I'm just going to plug in this formula here. So volume equals pi r squared h over 3, so I put that in there. The name of the function has to be on the left-hand side of an equal sign before that and again, it's entirely okay, if you guys have no idea what's going on. Because it really takes an entire course to learn how to do all this, but this is how you can make a user-defined function. And now, if I go back to my worksheet, I can type in, so let me first define a radius. So let's do a radius of 3, and I'm going to name this up here in the name box, name that Rad. And now, if I have a height of maybe 2, let's make that a little bit bigger like 6, then I can type a formula here because I've made that cone volume custom function. It had arguments radius and my height here and I can go ahead and press Enter and it calculates the volume of that. So every day, if you're using a certain function, you can create your own user-defined functions. Let me show you one more quick example. You probably know that there's Max function in Excel, you can calculate the maximum of that range. We can calculate the minimum using the Min function, but unfortunately, there is no range function. So you could easily calculate the range by just taking the maximum minus the minimum and that'll be 19, but let's go ahead and just make a quick range function that's going to be a custom function in VBA. So I'm going to go back over here in the same module, I'm just going to put this function range. The argument is going to be, I'm just going to call this DATARANGE as a Range, that's a type of data that you can declare. And this is just going to be I guess we're going to output a double and I'm going to say, the output is the name of the function. I can use one worksheetfunction.Max of our DATARANGE minus the Minimum using a worksheetfunction of our DATARANGE and when I go back into the spreadsheet, now, I can calculate the range by just using my range function. So range of, we put in our data and I press Enter and it gives me 19. So that's another example of how you might want to customize your worksheet environment. You can add in your own custom user-defined functions in VBA.