Page 11 - Excel for Scientists and Engineers: Numerical Methods
P. 11
...
Vlll EXCEL: NUMERICAL METHODS
For Each ... Next Loop ..................................................................................... 25
Nested Loops ................................................................................................. 26
Exiting from a Loop or from a Procedure ...................................................... 26
VBA Data Types .................................................................................................. 27
The Variant Data Type .................................................................................. 28
Subroutines ........................................................................................................... 28
Scoping a Subroutine ..................................................................................... 29
VBA Code for Command Macros ........................................................................ 29
Objects and Collections of Objects ................................................................ 29
"Objects" That Are Really Properties ............................................................ 30
You Can Define Your Own Objects .............................................................. 30
Methods ......................................................................................................... 31
Some Useful Methods .................................................................................... 31
Two Ways to Specify Arguments of Methods ............................................... 32
Arguments with or without Parentheses ........................................................ 33
Making a Reference to a Cell or a Range ............................................................. 33
A Reference to the Active Cell or a Selected Range ..................................... 33
A Reference to a Cell Other than the Active Cell .......................................... 34
References Using the Union or Intersect Method .......................................... 35
Examples of Expressions to Refer to a Cell or Range ................................... 35
Getting Values from a Worksheet ................................................................. 36
Sending Values to a Worksheet ..................................................................... 37
Interacting with the User ...................................................................................... 37
MsgBox .......................................................................................................... 37
MsgBox Return Values .................................................................................. 39
lnputBox ......................................................................................................... 39
Visual Basic Arrays .............................................................................................. 41
Dimensioning an Array .................................................................................. 41
Use the Name of the Array Variable to Specify the Whole Array ................ 42
Multidimensional Arrays ............................................................................... 42
Declaring the Variable Type of an Array ...................................................... 42
Returning the Size of an Array ...................................................................... 42
Dynamic Arrays ............................................................................................. 43
Preserving Values in Dynamic Arrays ........................................................... 43
Working with Arrays in Sub Procedures:
Passing Values from Worksheet to VBA Module ...................................... 44
A Range Specified in a Sub Procedure Can Be Used as an Array ................. 44
Some Worksheet Functions Used Within VBA
Create an Array Automatically ................................................................... 45
Some Worksheet Functions Used Within VBA
Create an Array Automatically ................................................................... 45
An Array of Object Variables ........................................................................ 45