1 00:00:00,570 --> 00:00:07,050 Hilary Rosen, welcome back to another class of our course about the complete introduction to VBA with 2 00:00:07,050 --> 00:00:08,290 Microsoft Excel. 3 00:00:09,300 --> 00:00:15,480 So basically in the past few classes, we talked about coding and basically we wrote some lines of code. 4 00:00:15,480 --> 00:00:17,670 We tried well, not we tried. 5 00:00:17,670 --> 00:00:18,810 We wrote down macros. 6 00:00:18,810 --> 00:00:20,280 We wrote our own macros. 7 00:00:20,550 --> 00:00:25,860 And not only our own macros, we actually created macros, our macros. 8 00:00:25,860 --> 00:00:28,440 We went inside of the code of those macros. 9 00:00:28,800 --> 00:00:30,470 So we did pretty much a lot of things. 10 00:00:31,290 --> 00:00:39,570 And what I figured out is that I didn't talk too much about everything that is inside inside of the 11 00:00:39,570 --> 00:00:39,990 code. 12 00:00:40,380 --> 00:00:42,890 And this is exactly what I want to do in this class. 13 00:00:42,900 --> 00:00:48,180 So it's going to be a little bit more theoretical and we are going to talk about each part of the code 14 00:00:48,180 --> 00:00:52,200 and what exactly we can find when we are writing VBA code. 15 00:00:53,070 --> 00:00:59,550 So what I propose you will what I want to talk about are basically a few fundamentals of the VBA coding. 16 00:00:59,730 --> 00:01:03,240 So we're going to talk about modules, about procedures. 17 00:01:04,290 --> 00:01:08,880 We want to talk about some other stuff, such as statements, objects and classes. 18 00:01:09,240 --> 00:01:13,220 So those things, in my opinion, are really important to understand. 19 00:01:14,070 --> 00:01:15,930 Yes, it's going to be a little bit more theoretical. 20 00:01:15,930 --> 00:01:20,730 But once again, in my opinion, it's really important to understand all of those elements. 21 00:01:21,720 --> 00:01:23,150 So let's start. 22 00:01:24,030 --> 00:01:24,420 All right. 23 00:01:24,750 --> 00:01:30,950 So what exactly we can find when we are writing a VBA program or even a code. 24 00:01:31,650 --> 00:01:34,740 So basically, first thing that we can find, we can find modules. 25 00:01:35,010 --> 00:01:38,610 So we talked about it at the beginning of the scores. 26 00:01:38,610 --> 00:01:44,430 Two modules are the place where we can store our macros to where the macros is going to be stored. 27 00:01:46,200 --> 00:01:53,310 We can see them as the warehouses are for what we can see as the warehouse for modules. 28 00:01:54,030 --> 00:01:57,210 So basically, this is well, there's a little mistake right there. 29 00:01:57,450 --> 00:02:00,630 What I want it to mean, we can see it as a warehouse for macros. 30 00:02:01,320 --> 00:02:03,630 So basically macros go inside of modules. 31 00:02:03,630 --> 00:02:09,690 So basically we can store a lot of macros inside of modules and it's composed of procedures. 32 00:02:09,690 --> 00:02:16,500 So to understand it, basically modules are the place where the macro is stored when it's created. 33 00:02:17,430 --> 00:02:23,510 So in other words, we can see it as a warehouse where all the code is going to be stored. 34 00:02:23,940 --> 00:02:32,070 So basically, well, normally or well, a standard module will be created with a set of procedures. 35 00:02:32,250 --> 00:02:34,140 So macros and procedures as well. 36 00:02:35,550 --> 00:02:41,340 So now it's time to understand what exactly is the procedure, because I always said that while there 37 00:02:41,340 --> 00:02:44,210 are macros inside of procedures, I will. 38 00:02:44,280 --> 00:02:46,640 Well, there are macros inside of modules. 39 00:02:46,640 --> 00:02:48,770 So basically what exactly is a procedure? 40 00:02:49,200 --> 00:02:55,470 So we can say that a procedure is basically a part of a computer program used to perform a task. 41 00:02:55,800 --> 00:02:58,070 And in VBA we have two of those. 42 00:02:58,080 --> 00:03:01,530 So we have some procedures and function procedures. 43 00:03:02,250 --> 00:03:09,090 And for the sub procedure, we can, for example, what we can, for example, think about that, the 44 00:03:09,090 --> 00:03:13,440 sub and function or the sub sub and procedure. 45 00:03:14,480 --> 00:03:20,720 So to understand a little bit better, basically a procedure is part of a computer program that is used 46 00:03:20,720 --> 00:03:22,340 to perform a certain action. 47 00:03:22,490 --> 00:03:29,810 So if we talk about that, about it, in other words, we can say that a procedure is a block of statements. 48 00:03:30,200 --> 00:03:38,060 Both are included by a particular declaration statement and an end statement. 49 00:03:38,090 --> 00:03:44,020 So, as I said, sub and statements in Libya, there is two types of procedures, as I said. 50 00:03:44,450 --> 00:03:49,160 So the first thing will be the sub procedures that are used to perform an action in Excel. 51 00:03:50,400 --> 00:03:58,290 So in other words, the declaration statement that will begin in a sub procedure will be a sub, so 52 00:03:58,290 --> 00:04:02,220 is a sub at the beginning of a sub procedure will be a sub procedure. 53 00:04:02,640 --> 00:04:03,560 Well, it's sorry. 54 00:04:04,040 --> 00:04:07,110 So basically, we have our sub and and sub at the end. 55 00:04:07,770 --> 00:04:10,950 This this is a statement, but this could be a sub procedure as well. 56 00:04:11,250 --> 00:04:18,060 So we can, for example, think about the first and last sentence of it, because, as I said, that 57 00:04:18,060 --> 00:04:19,170 starts with subs. 58 00:04:19,170 --> 00:04:21,550 So this can be an example of a sub procedure. 59 00:04:22,530 --> 00:04:26,140 And finally, the second type of procedure is a function procedure. 60 00:04:27,150 --> 00:04:33,780 So finally, a sub procedure do not return a value, but a function procedure can perform certain activities 61 00:04:34,110 --> 00:04:36,330 before returning a value. 62 00:04:38,160 --> 00:04:43,080 So now we are going to talk about what exactly are statements, because we talked about procedures and 63 00:04:43,080 --> 00:04:45,090 we talked about a little bit about the statements. 64 00:04:45,090 --> 00:04:52,630 When we talk about procedures for when we're talking about statements, we can divide them in two things. 65 00:04:52,650 --> 00:04:58,430 So, first of all, we have our declaration statements and our executable statements. 66 00:04:58,770 --> 00:05:00,360 So I'm going to explain it. 67 00:05:00,510 --> 00:05:05,920 Well, just just really basic that first and then I'm going to go a little bit more in-depth. 68 00:05:06,660 --> 00:05:09,240 So basically, the declaration statement is as written right there. 69 00:05:09,240 --> 00:05:10,530 It's really used well. 70 00:05:10,530 --> 00:05:17,040 It's usually used to declare a variable or a constant and finally executable statement will will be 71 00:05:17,040 --> 00:05:19,170 more a specification of something. 72 00:05:20,580 --> 00:05:25,950 So if we talk a little bit more in depth, so basically, as I said, the declaration statement will 73 00:05:26,250 --> 00:05:32,310 be usually used to declare something like, for example, a consonant or a variable. 74 00:05:33,090 --> 00:05:39,990 So we can, for example, think about the sub procedure where we can find a declaration statement in 75 00:05:39,990 --> 00:05:44,050 the opening of the sub statement that will declare this procedure. 76 00:05:44,070 --> 00:05:45,450 That is our market. 77 00:05:45,480 --> 00:05:50,400 So basically, we have our set procedure and then we will have the name of our magpul, basically. 78 00:05:50,430 --> 00:05:55,740 This will be a declaration statement that we declare the name of the macro as being the name of the 79 00:05:55,740 --> 00:05:56,090 macro. 80 00:05:57,630 --> 00:06:00,380 And the second thing will be the executable statement. 81 00:06:00,390 --> 00:06:06,000 So basically this statements are the specification that a certain action has to be taken. 82 00:06:06,030 --> 00:06:13,320 So basically it's to perform a search well, to perform an action or a certain type of action so we 83 00:06:13,320 --> 00:06:15,930 can, for example, think, well, we have a few examples for. 84 00:06:16,710 --> 00:06:23,190 So basically a simple example of this type of statement can be, for example, select or in other words, 85 00:06:23,190 --> 00:06:26,110 asking Excel to select some cells. 86 00:06:26,130 --> 00:06:32,190 So this would be a statement and an example of statement that can be used in your vehicle. 87 00:06:32,350 --> 00:06:36,690 And we use it more than once in the past few codes that we have written. 88 00:06:37,760 --> 00:06:38,100 All right. 89 00:06:38,390 --> 00:06:43,280 Next thing that we are going to talk about right now will be the objects and there are huge part of 90 00:06:43,280 --> 00:06:46,670 our world, basically of our Web programming. 91 00:06:47,480 --> 00:06:49,870 And what exactly are objects? 92 00:06:49,920 --> 00:06:52,660 It's like it's well, it's the same thing as written right there. 93 00:06:52,670 --> 00:06:56,450 It's to describe a certain action that will be performed. 94 00:06:56,930 --> 00:07:03,990 So basically, we can say that an object is simply a certain action that will be performed on itself. 95 00:07:04,460 --> 00:07:09,130 So in THEBA programming, we work with plenty of different objects. 96 00:07:10,280 --> 00:07:15,340 We can, for example, think about the things that we have right there. 97 00:07:15,740 --> 00:07:17,900 So we have, for example, workbooks, worksheets. 98 00:07:17,900 --> 00:07:25,190 We can have some other ones, like, for example, salvages cells and many other different objects. 99 00:07:25,580 --> 00:07:31,520 And for example, if we thought, well, we can talk about a few of them that we have used in the past 100 00:07:31,610 --> 00:07:39,140 few classes when we wrote our programs so we can, for example, think about the active cell and deselection 101 00:07:39,140 --> 00:07:40,730 cell that we have used. 102 00:07:40,760 --> 00:07:46,010 So if we look at our code, we used those two objects. 103 00:07:46,280 --> 00:07:51,170 So the first will refer to the current active cell in the current active workbooks. 104 00:07:51,200 --> 00:07:59,060 Right now we're talking about the active cell and deselection object is simply a reference to the current 105 00:07:59,060 --> 00:08:00,540 selected object. 106 00:08:01,050 --> 00:08:03,460 So basically, this would be for our object. 107 00:08:04,730 --> 00:08:08,830 Finally, the last thing that I want to cover would you guys will be the classes. 108 00:08:08,990 --> 00:08:12,610 So basically classes are a huge part as well of feeB Will. 109 00:08:12,620 --> 00:08:18,360 Basically, all the things that we talk about are huge parts, but classes are also really important. 110 00:08:18,380 --> 00:08:21,830 I'm not going to talk too much in depth about it because it's a bit more advanced. 111 00:08:22,730 --> 00:08:26,510 But in my opinion, it's also important to understand what exactly art classes. 112 00:08:27,110 --> 00:08:31,010 So basically classes are the element that defines objects. 113 00:08:31,370 --> 00:08:37,790 So in other words, how exactly we can see what we can say, that classes will define some aspects of 114 00:08:37,790 --> 00:08:43,820 an object so we can, for example, think about what we can think about a few things that can define 115 00:08:43,820 --> 00:08:44,250 an object. 116 00:08:44,300 --> 00:08:49,700 For example, the properties of the object be variables or the procedures that are used inside of a 117 00:08:49,700 --> 00:08:50,420 certain object. 118 00:08:52,310 --> 00:09:01,430 So when we're thinking about a class and an object together, we can say that this means basically one 119 00:09:01,430 --> 00:09:01,690 thing. 120 00:09:01,700 --> 00:09:08,720 So you can think, for example, that an object is an instance of classes, or we can simply say that 121 00:09:08,720 --> 00:09:10,780 classes are a blueprint. 122 00:09:10,790 --> 00:09:11,920 So basically classes. 123 00:09:11,930 --> 00:09:15,620 Well, there is a lot of classes that are part of one single object. 124 00:09:16,640 --> 00:09:18,870 So that's pretty cool to understand. 125 00:09:19,610 --> 00:09:26,080 So what we talked about in this course today are basically the basics of Excel that are, in my opinion, 126 00:09:26,090 --> 00:09:27,410 really important to understand. 127 00:09:28,220 --> 00:09:33,680 So first of all, we talked about modules that are a huge part of Excel and basically we are using them 128 00:09:33,680 --> 00:09:36,080 to store macros and procedures as well. 129 00:09:36,290 --> 00:09:42,920 We talked about what exactly is a procedure and how it works and basically what exactly is a procedure. 130 00:09:44,650 --> 00:09:51,520 We talked also about statements, objects and finally classes, so this course, today's a little bit 131 00:09:51,520 --> 00:09:57,910 more theoretical because in my opinion, this is really important for us to understand all those elements 132 00:09:57,910 --> 00:10:06,150 that are inside of feeB programming or if you guys want to program in debate and even if it's theoretical, 133 00:10:06,160 --> 00:10:10,870 well, it's really important to understand those elements as well. 134 00:10:11,290 --> 00:10:14,980 So that's a first class guys, all in our next class.