Microsoft Office Tutorials and References
In Depth Information
Making Decisions in VBA Code
Select Case value
[Case possibleValue [To possibleValue ]
[ statements ]]
[Case possibleValue [To possibleValue ]
[ statements ]]...
[Case Else
[ statements ]]
End Select
value is some value (such as a number), and possibleValue is any value
that could match the value. You can have any number of Case
possibleValue statements between the Select Case and End Select statements.
Optionally, you can include a Case Else statement, which specifies
statements that execute only if none of the preceding Case possibleValue
statements proves to be True.
Each Case statement can have any number of statements below it. When the
code executes, only those statements after the Case statement that match
the value at the top of the block execute. Figure 3-4 shows the idea.
Figure 3-4:
A Select
Chapter 3
Suppose that you create a custom option group named WhereTo and a
command button named OKButton on a form like the one in Figure 3-5. When
the user chooses an option and clicks OK, you want to have the appropriate
form open.
Search JabSto ::

Custom Search