# VBA Logical Operators in Microsoft Excel

The most common logical operators in VBA are: AND and OR. Each of these operators is very useful for evaluating conditions and making appropriate decisions about the code that will be executed

### The AND Logical Operator

The AND logical operator is the operator that helps us to enforce two conditions. This operator allows to execute a block of code that must meet condition1 AND condition2.

In the following example I have the qualification of two exams. Only if both exams have a grade higher than 3, then the student will be approved, otherwise the grade will be disapproval.

We are going to use an IF statement to compare the exams qualification with the grade condition. This comparison is that we usually do with the logical operators.

The code that will be executed when the button is pressed will be the following:

When we execute this code we will obtain the “Approved” result, this is because both exams have a rating greater than 3:

In this way we verify that the logical operator And helps us to force both conditions to be fulfilled. However, if the value of one of the cells is less than 3, then we will have a different result:

The logical operator And will return the true value only when both conditions are met and it will suffice that one of them is not met to obtain a negative result.

### The OR Logical Operator

The OR logical operator translates will allow us to know if at least one of the conditions is fulfilled, that is to say, if the condition1 OR condition2 is fulfilled.

If we change the previous example a bit and say that it is sufficient that one of the two grades is greater than 3 for the student to be approved, then we can modify the code as follows:

If any of the grades are higher than 3, then the student will be approved:

The only way the logical OR operator returns a false value is that none of the conditions are met. In our example, the student will be reprobate only when both grades are less than 3:

To conclude in the following table we can see in each case how the logical operators evaluate the condition:

Excel TotalĀ

# Excel Visual Basic (VBA) for Beginners to Cleanse a Dataset

This Excel video series helps Excel users just starting out with code in the Visual Basic program, or those who have never coded before, who are curious about it and just heard about it, about its powerful utilisation. In a lot of cases, Excel users find themselves engaged in tricky manual tasks in study subjets or work tasks, that take up time, create stress and lose of time. Data cleansing is one such task.

To explain that, if you have ever gone through a list of data and looked for mistakes (in dates or numbers, for example) then you have done a data cleansing task. With a little coding knowledge, that we are going to see in the following videos, it is possible to dramatically speed up this kind of task, reduce the stress and increase your productivity. You can learn more about Microsoft Excel go on here: Excel School

The 1st Part: Introduction

The 2nd Part: Beginning with VBA

The 3rd Part: Using Messaging Boxes

The 4th Part: Stopping the program

The 5th Part: Finishing and testing the program

# Multi Page Userform in Microsoft Excel

This is an Employee Database VBA Code in Microsoft Excel. Here you can learn how to construct the code in VBA that allows you to manage the employee database in your business. Save a lot of time creating this Excel Application using VBA code and Userforms. You can change the Userform too and customize it to your needs, learn the code logic and change the parameters that you need.

# Create a simple Userform in Excel

To create interactive Workbooks, to allow a good experience for the users of a Workbook or a Worksheet, create Userforms, that allows you to get data and put it in specific cells.