Microsoft Office Tutorials and References
In Depth Information
After you enter an instruction, the VB Editor performs the following actions to improve readability:
• It inserts spaces between operators. If you enter Ans=1+2 (without any spaces), for example, VBA converts
it to
Ans = 1 + 2
• The VB Editor adjusts the case of the letters for keywords, properties, and methods. If you enter the follow-
ing text:
user=application.username
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 specify 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 de-
clared.
• 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
dialog box (accessible by choosing Tools Options).
Like Excel, the VB Editor has multiple levels of Undo and Redo. Therefore, if you mis-
takenly delete an instruction, you can click the Undo button (or press Ctrl+Z) repeatedly
until the instruction returns. After undoing the action, you can choose Edit Redo De-
lete (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 the Excel macro recorder. No
matter how hard you try, you cannot record a Function procedure (the type of procedure that is used for a cus-
tom 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 username. Follow these steps in Excel:
1. Choose Developer Code Record Macro.
2. In the Record Macro dialog box, accept the default settings and click OK to begin recording.
The Record Macro button's caption toggles to Stop Recording.
3. Choose File Options and click the General tab.
4. Under the Personalize Your Copy of Microsoft Office heading, change the name in the User Name box.
Search JabSto ::




Custom Search