sheet or a UserForm.2009-08-20 00:06:41 楼主
The Visual Basic Editor (VBE) Edit toolbar contains two very useful buttons. Select a group of instructions and then click the Comment Block button to convert the instructions to comments. The Uncomment Block button converts a group of comments back to instructions. These buttons are very useful, so you might want to copy them to your Standard toolbar.
Sub Procedure2()
'' - [Code goes here] -
End Sub
Normally, the value of a module-wide variable does not change when a procedure ends normally (that is, when it reaches the End Sub or End Function statement). An exception is if the procedure is halted with an End statement. When VBA encounters an End statement, all module-wide variables lose their values.
PUBLIC VARIABLES
To make a variable available to all the procedures in all the VBA modules in a project, declare the variable at the module level (before the first procedure declaration) by using the Public keyword rather than Dim. Here''s an example:
Public CurrentRate as Long
The Public keyword makes the CurrentRate variable available to any procedure in the VBA project, even those in other modules within the project. You must insert this statement before the first procedure in a module (any module). This type of declaration must appear in a standard VBA module, not in a code module for a
STATIC VARIABLES
Static variables are a special case. They are declared at the procedure level, and they retain their value when the procedure ends normally. However, if the procedure is halted by an End statement, static variables do lose their values.












