If Then Statement

If Then Statement

Before you begin reading this tutorial, please review the VBA Logial Operator first for fast understanding.

The syntax for If Then Statement is shown below.

    If myCondition is TRUE then
        
        'Do this

    End If

Check the example below.



Create the example above in your own editor.

Try this: Change the value of A1 to MICHAEL.
             Run the macro.Nothing happens right? It's because your condition is already False that is why it will end sub.

For the concatenation of strings you can check this article.

Homework:
1. Create If then statement inside the For Next Loop.
2. Put any name in you range of cells from A1 to A10.
3. Every name inside the cell will be displayed in messagebox.

Our next tutorial is If Else statement.



No comments:

Post a Comment