VBA and Excel for Engineers and Scientists – Part 2

Code Containers

There are several different container types for your VBA code. For now, we’ll stick with the most common, a code "Module”. To create a code module, in the VBE, go to Insert->Module. In the Project Explorer on the left hand side, you should see at least one module for your XLS file, probably named "Module1″. You can change the name using the Properties window. If you don’t see the Project Explorer or the Properties Window, go to the view menu.

Figure 1: Project Explorer

For your reference, other code containers are various different forms of modules such as "Worksheet Code Modules,” which I generally recommend you avoid for now, "Form Modules,” which are used if you want to create your own input/output forms , and "Class Modules,” which are used for object-oriented programming. As far as object-oriented programming is concerned, you will become at least somewhat familiar with it because there are many built-in Excel Objects you will need to interact with in your VBA coding. However, I’m an engineer, not a programmer, so I am just looking for simple and functional code and I don’t care if its elegant or not! I’m guessing if you’re reading this, you are probably in the same boat, so forget about Class Modules for now.

1 Comment

Comments are closed.