

Now, all the codes which you enter must be between these two lines. When you type Sub IF_THEN() as the first message without any quotes around it, you can observe, Excel automatically adds the line End Sub below the first message line when you press Enter. You should use matching End If statement after entering the above syntax, When the condition meets or criteria evaluates to true, then all the lines between If Then and End If are processed. IF THEN is a simple form of VBA statement. The format to write a code is:

Now the blank module is created, it is also called a code window, where you can start writing if statement codes.Now go to the Insert menu from VBA window and select Module as shown below.

