Article ID: 213630 - Last Review: October 11, 2006 - Revision: 5.2 How to use the IF THEN ELSE statement and the SELECT CASE statement in examples written in Visual Basic for Excel 2000This article was previously published under Q213630 On This PageSUMMARY In Microsoft Visual Basic for Applications, there are two
statements that you can use to perform a conditional test: an If...Then...Else statement or a Select Case statement. The If...Then...Else statement executes a group of statements based on the value of an
expression, and the Select Case statement executes one of several statements based on the
value of an expression. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following sample macros show how to use the If...Then...Else and the Select Case statements. Sample Macro Using If...Then...Else StatementSample Macro Using Select Case StatementREFERENCES
For more information about using Select Case
statements, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Using Select Case
Statements in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about the IF statement, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Using If...Then...Else Statements in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For additional information about getting help with Visual Basic for Applications, please click the article number below to view the article in the Microsoft Knowledge Base: 226118
(http://support.microsoft.com/kb/226118/EN-US/
)
Programming resources for Visual Basic for Applications
For more information about how to use the sample code in this
article, click the article number below to view the article in the Microsoft
Knowledge Base: 212536
(http://support.microsoft.com/kb/212536/EN-US/
)
How to run sample code from Knowledge Base articles
| Article Translations
|

Back to the top
