Full Transcript

·YouTLDR

TUTORIAL VBA MACRO EXCEL Part 2: Object (Application, Workbooks, Worksheet, Range)

16:29EnglishBy talentedDIYTranscribed Jul 25, 2026
Analyze another video with Pro30-day money-back guarantee
0:01

Hi friends in this video we will learn to recognize objects what is an object why is it important because in the visual basic programming in Microsoft Excel itself we will manipulate or modify objects more what is an example of an example of an object in Microsoft Excel is a range so friends try to pay attention to box A1

0:31

This box A1 or this range or this cell is called an object I will fill this object with the word "learn" and inside it I will change the font to Times New Roman I change the font size to 15 I change the fill to yellow Next, I want to move this object to B1 then I will cut I paste again

1:05

All we do is manipulate object A1 which is now in B1 So friends, that's what we will do in our code writing we manipulate objects that already exist or later we can make our own object like what? friends, later we can

1:34

we see next now we want to see first examples of objects in Microsoft Excel itself how to open Visual Basic then friends can see in there is an object browser icon friends click then objects will appear this is the classes that are here all of this is called an object Wow quite a lot of friends don't worry first

2:06

Because not all of these objects we will use, there are some objects that we will use frequently, there are some objects that we rarely use, even some objects that we will never use. So friends, don't worry because we will try to study this one by one starting from the ones we will use frequently. First we will see the application object.

2:37

So, friends, the object in Microsoft Excel itself has a hierarchy. If I take it as a house, the house is an object. And in the house there is a room, which is also called an object. And in the room there is a closet, which is also called an object. And in the closet there is a rack, which is also called an object. So I can say that the object can

3:06

is in another object and another object can be in another object how about Microsoft Excel? Microsoft Excel itself has the largest object is the application or Microsoft Excel itself there is an application so when we want to modify the application or like a house then I have to go home first then I can modify the house

3:37

When I want to modify the room, then I have to go to his house, then enter the room that I want to modify. If the room has 3 rooms, room A, B, and C, if I want to modify room A, then I have to enter room A. Likewise with Microsoft Excel.

3:57

In the application there is a workbook where we can work more than one workbook Right now, friends, I work on a workbook called Book 1 This is also an object where I can delete this workbook, I can add it And inside there is also a worksheet, which is smaller, this is a worksheet I can manipulate this worksheet, I can add, I add again, I add

4:28

and in the worksheet the smallest is the range okay friends we will try to see one of the examples here I have two workbooks there are two workbooks and now I want to exit workbook 2 okay then when I write the code I close this first, we'll come back here later I write the code sub exit to write the code friends

5:10

what I have to do because I want to exit Book 2 if I'm outside this house then what I have to do is I have to go inside the house first so I have to call the application first after entering the house to connect the object with another object we use a dot after entering the house I give a dot sign I go to room 1 after heading to room 1 the name of the object here happens to be room 1 I represent it like

5:42

Book 2, sorry I'm going to room 2 where I'm like a book 2 Now I write workbook, sorry, workbook, done, workbook, the one with the S, why? Because in the one with the S there are many workbook collections, but which workbook will we choose? How to choose which workbook? Please open the title, write the name of the workbook, by chance this is workbook 2, write book 2, close the title, done

6:15

after this I want to exit then choose the choice of close then what will come out later is workbook 2 not workbook 1 I will give one more example that is more complete, how about worksheet

6:51

here I still have two workbooks I will make a sub add sheet delete sheet then I will start from the application first if you are now outside the house then application first dot workbook open the title name of the workbook for example book 1

7:39

Next, after from the room earlier, friends will go to the closet, which is the same as the sheet, which means I type worksheet, yes worksheet, open the box, which sheet is the first sheet, dot delete, I want to delete, enter friends, let's see this is the first sheet, yes, for book 1, I run, delete, this is deleted, the first sheet is deleted,

8:13

friends, don't worry about the steps of writing the code first, the most important thing is to understand the principles first because we will continue to learn this code writing in the next videos okay friends actually this code writing is too long we can make it short for example if I want to delete if I want to delete sheet 1 friends see sheet 1 but what is in book 3 then

8:50

then I will type the application workbooks books 3 worksheet sheet 1 is delayed this is the long step assuming you are outside the house the problem is that you are not outside the house now if you want to access room 3 and the closet in room 3 then if the position you are in the room now

9:18

then it's more simple if you don't need to go out of the house you're just in room 3 and open the closet unless you're not in, for example, you want to access room 3 now you're in room 1 so what you do is you don't need to go out of the house you just move between rooms okay? the same principle here, where is my position? where is our position? in book 3

9:50

It means if I want to delete Book 3 I don't need to go to Microsoft Excel Do I need to go to Workbooks Book 3? No need Because it's clear I'm in Book 3 Do I need to go to worksheet sheet 1 to delete? Need Because this is our goal We are in Book 3 and want to delete sheet 1 Please run it, friends When, oh, this can't be This worksheet

10:28

Oh because we don't have one sheet, friends, there are only two sheets, three sheets and four sheets, I change it to one, I change it to two, if I change the two sheets, then I run, yes, this is erased, okay, so friends, you understand, we can make it much more concise. Next, friends, we will try to learn how to make our own objects, this is enough

10:57

more complex than before but calm down friends like what I said before that the main concept is because in the future we will have more training I will use sub for example add objects

11:18

I want to add an object, for example, an object that is not yet in Excel, one of them is a fruit, for example I want to enter the name of the object as a fruit and inside the fruit there is an apple, there is another object, that is, an apple, there is a grape, and so on. Okay, now I want to add an object, what I do is use dim

11:40

friends later if you want to learn more about DIMM here I don't explain about DIMM later friends can see my other videos that explain about DIMM DIMM fruit as new collection means I want to add fruit as a new object we use collection so the new object will be stored in the collection friends

12:16

this fruit has become a collection, has become a group, has become an object inside the fruit I want to add so fruit, I want to call fruit, dot, I want to add, I want to add apple next I want to add grapes too now we already have a collection, we already have a fruit object where there are two items inside, there are apples and grapes

12:51

let's see if it's really there we debug.print oh friends I haven't explained this yet debug.print what is it we use this friends if we want to run the command and see the results in one window called immediate window friends can see here in view immediate window later

13:27

the result will appear here so we can test the command we made here this is debug.print after that, make a .count count means the number of items in the fruit object there should be two so when I run it, there should be two friends can see there are two here it means we have successfully added a new object the name of the object is fruit there is another way to add objects it's just different in the writing

14:01

I add an object called DimMotorSCollection this is not Snew I only use S next I want to make this motor as an object DimMotorSCollection to make it an object then set motor

14:49

= new collection I just made this step the next step is the same as above means motor.ed I want to add for example Honda motor.ed I want to add Yamaha motor.ed I want to add Suzuki we already have

15:26

an object motor where in this motor there are three objects namely Honda, Yamaha and Suzuki to see the results like above friends use debug then motor dot com please run then the result will be three so this is correct this is quite different friends actually the principle is the same but in Korean writing later this is different why with this method we can add

16:01

procedures or other functions inside it, we can add for example the IF function and so on, okay friends, so we have learned to know the object, I hope you are not confused first because basically as I said at the beginning that we learn the principles first how we want to modify manipulating the existing object, thank you friends for joining me

Continue with YouTLDR

Analyze another video with Pro

Process a new video, search every timestamp, compare sources, and keep the result in your library.

Get Pro — $12/month30-day money-back guarantee

More transcripts

Explore other videos transcribed with YouTLDR.