The VB Editor adjusts the case of the letters for keywords, properties, and
methods. If you enter the following text:
VBA converts it to
user = Application.UserName
Because variable names are not case sensitive, the VB Editor adjusts the
names of all variables with the same letters so that their case matches the
case of letters that you most recently typed. For example, if you first spec-
ify a variable as myvalue (all lowercase) and then enter the variable as
MyValue (mixed case), VBA changes all other occurrences of the variable
to MyValue. An exception to this occurs if you declare the variable with
Dim or a similar statement; in this case, the variable name always appears
as it was declared.
The VB Editor scans the instruction for syntax errors. If it finds an error, it
changes the color of the line and may display a message describing the
problem. You can set various options for the VB Editor in the Options dia-
log box (accessible by selecting ToolsOptions).
Like Excel,the VB Editor has multiple levels of Undo and Redo.Therefore,if
you find that you mistakenly deleted an instruction,you can click the Undo
button (or press Ctrl+Z) repeatedly until the instruction returns.After undo-
ing the action,you can select EditReDo Delete (or click the ReDo Delete
toolbar button) to redo previously undone changes.
USING THE MACRO RECORDER
Another way to get code into a VBA module is to record your actions by using
Excel’s macro recorder. No matter how hard you try, you cannot record a Function
procedure (the type of procedure that is used for a custom worksheet function). All
recorded macros are Sub procedures. Using the macro recorder can help you to
identify various properties that you can use in your custom functions. For example,
turn on the macro recorder to record your actions while you change the user name.
Follow these steps in Excel:
1. Select Tools MacroRecord New Macro.
2. In the Record Macro dialog box, accept the default settings and click OK
to begin recording. Excel displays a small toolbar named “Stop
Part VI: Developing Custom Worksheet Functions