4.1 Types of Macros Part 4

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
8 hours 33 minutes
Difficulty
Intermediate
CEU/CPE
9
Video Transcription
00:00
so so far you have seen how we create Mac Rose as a subroutine. Whether we recorded or we type it,
00:09
it's a 17 that can be cold from another 17 or function.
00:14
But now let's create a function
00:17
within Excel using macros, a visual basic.
00:23
This function can be then cold in a cell like any of the other functioned. It exists in visual basic
00:31
that would take a visual basic.
00:35
We go to insert, we have module,
00:38
we select module
00:40
and then we type
00:44
function.
00:48
They're going to call it the oregano, and it's going to have
00:52
all right, number one
00:54
and them, too.
00:58
Parameters
01:02
and dysfunction is going to calculated the agonal off a triangle has one
01:07
right angle. So
01:11
sorry. Straight at the 90 degree angle. So, um,
01:15
it's, um
01:19
yeah, you know
01:21
is equal
01:23
two
01:25
sq r
01:27
off
01:30
them one,
01:34
someone,
01:37
waas
01:38
two.
01:40
Multiply it
01:44
but itself.
01:47
And, uh,
01:51
we just say, like save because this is it.
01:53
It's going to take number one. It's going to multiplied by itself. It's going to add number two multiplied by itself,
02:00
and then it's going to calculate square root of it.
02:07
And when we do this first time get this message which says that
02:13
we cannot save dysfunction
02:15
in a standard X l s X format. We have to save it in a format that supports my crows.
02:23
So we take here or no,
02:25
we get the same file and then here we select type as ex Elice em
02:32
save
02:35
you Close this.
02:37
And now we have
02:38
this module here as ex Ellis M, meaning that it campaigns macros.
02:44
So
02:45
didn't just stay there, Colonel
02:47
and Selectees too.
02:53
And the cantor and we get the number here,
02:57
which is exactly that. So,
02:59
um, just to make sure that
03:02
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
03:16
that has to size three and four, the agonal is five.
03:21
So, uh, it's all about
03:23
well, how to create
03:27
Ah, you function.
03:30
And
03:31
what you have seen is also
03:35
that there. And I start typing equals and I just out d I
03:39
You get diagonal. So Excel already has put this function in the list of functions
03:46
and it's there. Andi, also,
03:50
if I go here, insert. Sorry.
03:54
Just this.
03:57
Okay,
03:58
Go into formulas and go to insert function.
04:01
And I say all and I go here.
04:06
It should be in the list.
04:12
Here it is.
04:13
So it's added to the list of all functions
04:16
in excel. So now you know what's the difference between sub macro and function macro and how to create one and the other.
04:28
And in, ah, next lesson, I'm going to talk about some other things that you can nicely do
04:35
in macros. Visual Basic.
04:40
So thank you.
Up Next