VBA and Excel for Engineers and Scientists

VBA and Security

The first thing you will need to do before we get to any VBA coding is to check your security settings in Excel. You can do this by going to Tools-Macro-Security from the menu. You need to set it to MEDIUM, which compromises between asking you if you want to open spreadsheets that contain macros and not allowing VBA code to run at all.

Because of the risk of macro viruses, make sure you have a decent antivirus program and NEVER open a suspicious Microsoft Office document, especially from someone you don’t know!

Getting Started with VBA

The next thing you need to do is to start getting familiar with the various toolbars, menus, windows and other elements that you will need as you are writing VBA code. First, check out your Macro toolbar. You can turn it on by right-clicking on your toolbar area and checking it or you can simply use the Tools>Macro menu.

Once you find your Macro Toolbar or menu, launch the Visual Basic Editor (VBE) using the appropriate button or menu command. Notice a few important windows and areas.

The Menu Bar where you will find some important buttons like the play, stop, step into, and object browser buttons.

The Project Explorer where you manage multiple code modules etc. In this window, you will see that each open spreadsheet is listed. Any Add-ins (like Acrobat) that are running will also be displayed. You can expand the tree for each object. Each Excel worksheet, chart, code module, form or other object is listed here. This is where you manage the code and any user forms for your VBA project.