Updated December 22, 2023
part-3 – Visual Basic Editor (VBE) – Project Explorer
Transcript for Video – Visual Basic Editor (VBE) – Project Explorer
Video on Visual Basic Editor (VBE) – Project Explorer – Now that we have looked at first Macro let us now go back to a Developer tab were we kind of looking at visual basis editor and kind of understand what these whole think is all about so if you are opening for first time from the Developer Tab and you can actually press ALT + F11 or you can click this icon which I did just now so you will see by default that there are many windows here the one is the VBA project that’s the file name and it’s also the project name and there is the property sheet and then there is local window and watch window so a so as you can see there is cross here against every window so you may want to kind of close this and kind of you know totally delete this that can also be done the reason we are doing this here is that I just wanted to show you that this are kind of highly customizable as per your requirement whichever is the need of the are you can actually keep that for the time being now why don’t you have look at these icon the top the once which we are going to learn in this video is the project explorer so as it is prompted CTRL R is also you can use so I’ll click here this is all about the project explorer so here what we see is that we see a tree structure which mention something like VBA project and VBA project.xls so essentially treats every workbook as a project so excel actually treats work book as project and if you look at what is inside pre structure it says Microsoft excel objects these are sheet 1, sheet 2, sheet 3 and this work book so let me double click on sheet 1 and the movement I’ll do that find you will white page that open up if you remember form are first macro there was something which was written here and essential this is the place where your code actually is written so don’t worry about this we will be discussing all of this as in terms of what is coding do all about but for the time being I was actually here and you know discussing that each sheet can have its own set of codding environment and these sheet1, sheet2, and sheet3 and this workbook all of this actually called as objects while we are discussing this in respect to the VBA’s another think to note within the VBA project explorer is that the No. of sheets here sheet 1, sheet 2 and sheet 3 and this workbook for the codding purposes while there was 3 sheets this is basically the way excel actually creates workbook by default there are 3 worksheet which are available but we obviously increase no of worksheet so let me kind of do that this is sheet 4 which I have inserted let say sheet 5 and let me go back and look at what happens In visual basic editor now you can see that the no of sheets have kind of increase from 3 to now 5 so you can have 10 sheets 15 20 sheets depending on your requirements and all this sheet which are treated object will listed here another think probably much important is that what if I change the name of sheet here let say sheet 1 if I changes to a sheet 2 to let say B and sheet 3 C, D and E so what happens to the naming within the visual basic project explorer so as you can see here now the name per say which is actually starts doesn’t change in the bracket you can see the name actually is changed so it says A, B , C, D E and this workbook so as we have discuss earlier that you know when we double click on sheet 1 the project or code environment opens up with respect to sheet 1 so you can actually write the code here you know something like Macro A so this is for the sheet A likewise you can write this for macro B you can write this same for macro C which is for sheet 3 and you can keep on doing this and let say sheet 5 sub E now probably you may have written this codes individually and you can see that you can access this codes within this worksheet you can do but double clicking individual worksheet and first question probably that should come into your mind is that let say if I have written code in this kind of format within each worksheet if there were 20 worksheet I would have navigated across this 20 worksheets in order to access this individual code which would have been really difficult so a the solution to this problem to here actually is that you can make use of function called insert module so can click here on insert and you can click here module so movement you do that you can see that your project explorer window actually have another node so earlier there was only Microsoft excel objects now it also has module and here within module when you double click you can write your sub routines on you know let say module 1 module 2 as micros so please note that in this module you can write more than 1 sub routine so you can have 15, 20, 25 30 you know you can write as many sub routines as you want and another think to actually note is that you can also insert couple of other modules 2, module 3 so on so fourth you know you will actually find that 90% of the VBA macro coders actually prefer this module and approach were they can use this module 1 for specific purpose, module 2 for another purpose, module 3 for another purpose and they can create clear you know architecture of their code using modules 1 reason could be that this is more organizationally we better than what we find within the individual codes so that’s how actually this module works and the you can also find that this module 1, module 2, 3 can be renamed we will explain this when we discuss about the properties of the VBA explorer widow but think about this as module 1 can be renamed as let say employee code and module 2 to may be departments codes and you can renamed it and it provides lot of flexibility however you will find that in this sheet the renaming is kind of literally difficult as you can see sheet 1 bracket A so you cannot renamed this sheet 1, sheet 2, sheet 3 in that kind of format which is desired for the VBA codding now another think probably you can look at is that you may want to insert other objects which are like you know user form or may be class module we will not discuss this user form and class modules for the time being we will discuss this in our future serious video tutorials but think of this as again the objects within this projects called VBA projects so earlier there was only 1 objects within which they were within other set of objects now there are 4 nodes which consists of forms and class modules we will discuss this 2 later and that’s where you know probably we leave the project discursion in time for the being probably last couple of thoughts here as you can see that we had mentioned earlier that MS Excel treats each workbook as project right so lets create, let’s probably you know open another workbook and I’ll open a new workbook called let say book 1 and this is another workbook and it has only 1 sheet so I’ll create let say you know 10 sheets here and this is my new workbook. Now I am just trying to explain what is meant by Microsoft Excel treating workbook as project so let me now go to the Developers tab and click here on visual basic ok so movement I’ll do that you can see that there are essentially 2 projects instead of 1 which was earlier now this is VBA project book 1 and then the current one which were currently working on that was VBA project.xls and within this B1 you can see that there are 10 sheets, sheet1, sheet2,3,4, so these are kind of treated as separate project all together see the beauty of treating MS Excel work book as project is that you may be working here within this sheet 1 codding or maybe you would be doing something here writing some code for new work book and you know you may immediately shift to probably VBA project sheet 1 and write a new some routine here so it’s actually provide you lot of flexibility to move around and do things when it is about codding so this is how you know excel actually treats this things as project 1st things that probably I would like to Infosys here is that how do you delete the module so if there are 3 module and probably you just required tools you may want to kind of delete the 3rd one for doing that you can actually right click after selecting the module click here on remove module 3 and it ask you for prompt which says do you want to export module 3 before removing it so if you want to use this module 3 at some other place you may want to click yes and then imported use it however if you don’t want it you can just click no and you will module will get deleted so this is basically about the project explorer for the time being now we will move to the properties discursion and see what this is all about.