![]() Or, click on the Insert Module button which you will find on the standard ribbon. To insert a new module into your code, click on the Insert option on the menu bar, and click Module. Inserting a module or form into your code It is good coding practice to ‘group’ your code into relevant modules – for example put all the global variables in one module, all public functions in another module etc. When your write your VBA code, you will usually use more than one module. Class module are used by Advanced VBA programmers and will be covered at a later stage. Class modules – this module is used to create objects at run time.The module behind a custom form that you create is also an Object module. The module can also contain code that is written by yourself and used by the events. ![]() An event can occur when a workbook is opened or closed for example, or when a sheet is clicked (the Click Event). Most of the code in these type of modules are known as EVENTS. ![]() Object modules – these type of modules hold the code the is unique to that individual workbook or worksheet.When you write a general procedure to be used throughout your workbook, it also normally goes into a standard module. When you record a macro, it gets put into a standard module. Standard modules – most of your code will go into this type of module.The modules are organised into 3 different types. This is useful when you want to re-use code in a different file, and therefore perhaps import that module into a new file. ![]() Modules can also be exported out of the parent file and saved as their own individual files. The modules are contained within a VBA Project and when the file is saved – be it an Excel workbook, Word document or Access database, the module or modules are saved within that file – that file is essentially the parent application of the module. Importing a VBA module or form into your VBA ProjectĪ VBA module is used to store any VBA code that you have written in the VBE (Visual Basic Editor).Exporting a module or form from the Project Explorer.Removing a module or form from the Project Explorer.Creating a new procedure – Alternative Method.Inserting a module or form into your code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |