Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. Using If...Then...Else statements (VBA) | Microsoft Learn

    To run only one statement when a condition is True, use the single-line syntax of the If...Then...Else statement. The following example shows the single-line syntax, omittin…
    Overview

    Use the If...Then...Else statement to run a specific statement or a block of statements, depending on the value of a condition. If...Then...Else statements can be nested to as many levels as you need.
    However, for readability, you may want to …

    Running certain statements if a condition is True and running others if it's False

    Use an If...Then...Else statement to define two blocks of executable statements: one block runs if the condition is True, and the other block runs if the condition is False.

    Testing a second condition if the first condition is False

    You can add ElseIf statements to an If...Then...Else statement to test a second condition if the first condition is False. For example, the following function procedure computes a bonus based on job classification. The statement following th…

    See also

    Support and feedback
    Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

  2. How to Use If Then Else Statement in Excel VBA (4 Examples)

      1. Assessment of Students’ Grades (Adding Text Based on a Certain Value with OR …
      2. Extracting Specified Word from Code Based on Condition. If we have short codes as …
      3. Commenting on Product Price. Now in this third example, we will work to attach …
      4. Use of If Then Else Statement to Set Multiple Conditions with Variables in Excel VBA. …
  3. If Then Else Statement in Excel VBA (explained with examples)

    • See More

    In this tutorial, I’ll show you different ways the ‘If Then Else’ construct can be used in Excel VBA, and some practical examples in action. But before I get into the specifics, let me give you the syntax of the …

  4. MS Excel: How to use the IF-THEN-ELSE Statement (VBA)

    This Excel tutorial explains how to use the Excel IF-THEN-ELSE statement (in VBA) with syntax and examples. The Microsoft Excel IF-THEN-ELSE statement can only be used in VBA code.

  5. People also ask
  6. Excel VBA IF THEN Statement (and a useful tip) - XelPlus

    • See More

    Aug 23, 2018 · In this tutorial, you’ll quickly learn how to work with the IF, THEN, ELSE, ELSEIF as well as the AND statements. This way you can write Excel macros that are dependent on multiple conditions.

  7. If Then Statement in Excel VBA - Step by Step Tutorial

    Use the If Then statement in Excel VBA to execute code lines if a specific condition is met.

  8. Conditional Statements: If, Else-If, If-Then And Select Case

    Apr 1, 2025 · This tutorial explains various conditional statements in VBA such as If, Else-If, If-Then, Nested If, And Select Case with examples.

  9. VBA IF (IF Then Else Statement to Write Conditions)

    In the above example, I have used the IF-Then-Else statement to check the value in cell A1. If cell A1 has a value of 10, you will get a message box showing “Cell A1 …

  10. How to use If-Else Statement in Excel VBA?

    Jul 23, 2025 · To optimize the performance and reduce the time in Excel we need Macros and VBA is the tool used in the backend. In this article, we are going to …

  11. How to Use VBA Conditional Statements in Excel (4 …

    Jul 29, 2024 · The article shows 4 basic examples on excel vba conditional statements. If, With, For Loop, Select Case etc. conditional statements are shown.