8 hours 33 minutes
so so far you have seen how we create Mac Rose as a subroutine. Whether we recorded or we type it,
it's a 17 that can be cold from another 17 or function.
But now let's create a function
within Excel using macros, a visual basic.
This function can be then cold in a cell like any of the other functioned. It exists in visual basic
that would take a visual basic.
We go to insert, we have module,
we select module
and then we type
They're going to call it the oregano, and it's going to have
all right, number one
and them, too.
and dysfunction is going to calculated the agonal off a triangle has one
right angle. So
sorry. Straight at the 90 degree angle. So, um,
yeah, you know
we just say, like save because this is it.
It's going to take number one. It's going to multiplied by itself. It's going to add number two multiplied by itself,
and then it's going to calculate square root of it.
And when we do this first time get this message which says that
we cannot save dysfunction
in a standard X l s X format. We have to save it in a format that supports my crows.
So we take here or no,
we get the same file and then here we select type as ex Elice em
you Close this.
And now we have
this module here as ex Ellis M, meaning that it campaigns macros.
didn't just stay there, Colonel
and Selectees too.
And the cantor and we get the number here,
which is exactly that. So,
um, just to make sure that
this is correct, we're going to type here three and four and we get five because it's ah, it's a common knowledge. If you remember your math in high school that to the triangle
that has to size three and four, the agonal is five.
So, uh, it's all about
well, how to create
Ah, you function.
what you have seen is also
that there. And I start typing equals and I just out d I
You get diagonal. So Excel already has put this function in the list of functions
and it's there. Andi, also,
if I go here, insert. Sorry.
Go into formulas and go to insert function.
And I say all and I go here.
It should be in the list.
Here it is.
So it's added to the list of all functions
in excel. So now you know what's the difference between sub macro and function macro and how to create one and the other.
And in, ah, next lesson, I'm going to talk about some other things that you can nicely do
in macros. Visual Basic.
So thank you.