Page 271 - Excel Data Analysis
P. 271
15 537547 AppC.qxd 3/4/03 11:56 AM Page 257
VBA AND EXCEL EVENTS QUICK REFERENCE C
VBA STATEMENTS QUICK REFERENCE (CONTINUED)
Program Flow
STATEMENT DESCRIPTION
[Public | Private] Declare Sub name Lib "libname" Declares a reference to an external
[Alias "aliasname"] [([arglist])] DLL library function.
Do [{While | Until} condition] Repeats a block of statements while
[statements] or until a condition is True. The
Loop condition is checked at the
beginning of the loop.
Do Repeats a block of statements while
[statements] or until a condition is True. Because
Loop [{While | Until} condition] the condition is checked at the end
of the loop, the block of statements
always executes at least once.
Exit Do | For | Function | Property | Sub Exits the specified Do Loop, For
Next, Function, Sub,or
Property code.
For Each element In group Repeats a block of statements for
[statements] each element in an array or
Next [element] collection.
For counter = start To end [Step step] Repeats a section of code the
[statements] specified number of times.
Next [counter]
[Public | Private | Friend] [Static] Function name [(arglist)] [As type] Defines a procedure that returns a
[statements] value.
[name = expression]
End Function
If condition Then Conditionally executes a block of
[statements] statements based upon the value of
an expression
[ElseIf condition-n Then
[elseifstatements] ...
[Else
[elsestatements]]
End If
[Public | Private | Friend] [Static] Property Get name [(arglist)] [As type] Declares the name and arguments
[statements] procedure that gets the value of a
[name = expression] property.
End Property
[Public | Private | Friend] [Static] Property Let name ([arglist,] value) Declares the name and arguments
[statements] of a procedure that assigns a value
End Property to a property.
[Public | Private | Friend] [Static] Property Set name ([arglist,] reference) Declares the name and arguments
[statements] of a procedure that sets a reference
End Property to an object.
257