The Excel Visual Basic EditorSearch this site:
Custom Search
The easiest way to access the Visual Basic Editor in Excel is to press the key combination ALT-F11 (ie. press the ALT key, and while this is pressed down, press F11). You will be presented with the Visual Basic Editor, similar to the image below (note that your normal Excel window will remain open behind this window).
There are a number of windows that can be viewed in the Excel VBA Editor. These are controlled via the View menu at the top of the VBA Editor window. The individual windows are described below. The Project WindowThe Project Window opens up on the left of the VBA Editor (as shown in the above image). This window provides you with an index of all Visual Basic files, linked to all open Excel workbooks. These consist of :
If you want to write a macro that is to be linked to a specific worksheet, then this code should be entered into the relevant worksheet object. If your code is more general, you may want to create a new module to hold this. The Code WindowsThe Code Window show the VBA code for each individual worksheet object or module. You can open the code window for an existing worksheet object or module by double-clicking on the name in the Project Window. (In the image above, the worksheet object for Sheet1 of the workbook is displayed, although it contains no VBA code at present).Alternatively, to create a new module:
The Properties WindowThe Properties Window lists the properties of the object that is selected in the Project Window at design time (ie. not during run time). These properties vary, depending on the type of object that is selected (a worksheet, workbook, module, etc).The Immediate WindowThe Immediate Window assists with the debugging of code by allowing you to execute individual lines of code. This is done by typing in an individual line code and then pressing enter to execute it.The Locals WindowThe Locals Window displays all local variables that are declared in the current procedure. The window is split into columns which show the name, value and type of each variable. These are updated automatically as the programme is executed. This window is therefore useful to assist with debugging.The Watch WindowThe Watch Window is also useful to assist with debugging procedures. This window shows the value, type and context of any watch expressions that have been defined by the user. It will appear automatically when a watch expression is defined, or it can selected from the View window.A 'watch' expression can be defined by the following steps :
The menus at the top of the Excel Visual Basic Editor contain numerous options and commands for designing, executing and debugging VBA code. Further information on the VBA editor can be found on this site (opens in a new window). |
|||||||||
|
|
|||||||||
Copyright © 2008-2010 ExcelFunctions.net |
|||||||||
