Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit 3147b51

Browse files
authored
Merge pull request #546 from dangowans/patch-1
select-case-statement.md - Formatting
2 parents af2fd0c + 5ed46e4 commit 3147b51

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

VBA/Language-Reference-VBA/articles/select-case-statement.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,30 @@ Executes one of several groups of [statements](vbe-glossary.md), depending on th
1515

1616
**Syntax**
1717

18-
**Select Case**_testexpression_
19-
[ **Case**_expressionlist-n_
18+
**Select Case** _testexpression_
19+
[ **Case** _expressionlist-n_
2020
[ _statements-n_ ]]
2121
[ **Case Else**
2222
[ _elsestatements_ ]]
2323

2424
**End Select**
25+
2526
The **Select Case** statement syntax has these parts:
2627

2728

2829
|**Part**|**Description**|
2930
|:-----|:-----|
3031
| _testexpression_|Required. Any [numeric expression](vbe-glossary.md) or[string expression](vbe-glossary.md).|
31-
| _expressionlist-n_|Required if a **Case** appears. Delimited list of one or more of the following forms: _expression_, _expression_**To**_expression_, **Is**_comparisonoperator_ _expression_. The **To**[keyword](vbe-glossary.md) specifies a range of values. If you use the **To** keyword, the smaller value must appear before **To**. Use the **Is** keyword with[comparison operators](vbe-glossary.md) (except **Is** and **Like** ) to specify a range of values. If not supplied, the **Is** keyword is automatically inserted.|
32+
| _expressionlist-n_|Required if a **Case** appears. Delimited list of one or more of the following forms: _expression_, _expression_ **To** _expression_, **Is** _comparisonoperator_ _expression_. The **To** [keyword](vbe-glossary.md) specifies a range of values. If you use the **To** keyword, the smaller value must appear before **To**. Use the **Is** keyword with [comparison operators](vbe-glossary.md) (except **Is** and **Like**) to specify a range of values. If not supplied, the **Is** keyword is automatically inserted.|
3233
| _statements-n_|Optional. One or more statements executed if _testexpression_ matches any part of _expressionlist-n._|
3334
| _elsestatements_|Optional. One or more statements executed if _testexpression_ doesn't match any of the **Case** clause.|
34-
**Remarks**
35-
If _testexpression_ matches any **Case**_expressionlist_ expression, the _statements_ following that **Case** clause are executed up to the next **Case** clause, or, for the last clause, up to **End Select**. Control then passes to the statement following **End Select**. If _testexpression_ matches an _expressionlist_ expression in more than one **Case** clause, only the statements following the first match are executed.
36-
The **Case Else** clause is used to indicate the _elsestatements_ to be executed if no match is found between the _testexpression_ and an _expressionlist_ in any of the other **Case** selections. Although not required, it is a good idea to have a **Case Else** statement in your **Select Case** block to handle unforeseen _testexpression_ values. If no **Case**_expressionlist_ matches _testexpression_ and there is no **Case Else** statement, execution continues at the statement following **End Select**.
35+
36+
**Remarks**
37+
38+
If _testexpression_ matches any **Case** _expressionlist_ expression, the _statements_ following that **Case** clause are executed up to the next **Case** clause, or, for the last clause, up to **End Select**. Control then passes to the statement following **End Select**. If _testexpression_ matches an _expressionlist_ expression in more than one **Case** clause, only the statements following the first match are executed.
39+
40+
The **Case Else** clause is used to indicate the _elsestatements_ to be executed if no match is found between the _testexpression_ and an _expressionlist_ in any of the other **Case** selections. Although not required, it is a good idea to have a **Case Else** statement in your **Select Case** block to handle unforeseen _testexpression_ values. If no **Case** _expressionlist_ matches _testexpression_ and there is no **Case Else** statement, execution continues at the statement following **End Select**.
41+
3742
You can use multiple expressions or ranges in each **Case** clause. For example, the following line is valid:
3843

3944

@@ -72,7 +77,7 @@ Case 1 To 5 ' Number between 1 and 5, inclusive.
7277
Case 6, 7, 8 ' Number between 6 and 8.
7378
Debug.Print "Between 6 and 8"
7479
Case 9 To 10 ' Number is 9 or 10.
75-
Debug.Print "Greater than 8"
80+
Debug.Print "Greater than 8"
7681
Case Else ' Other values.
7782
Debug.Print "Not between 1 and 10"
7883
End Select

0 commit comments

Comments
 (0)