Conditional Logic
Conditional logic is a very versatile way to develop your codes in Excel. The conditional logic feature is what will help you differentiate between different information and different cells in your worksheet, which is the thing that you will usually be working with most of the time. Conditional logic is usually very difficult at first glance for people who do not have previous coding experience, but it makes perfect sense and only takes a few tries before you become a professional at it. There are a few different types of logic that Excel recognizes, and we will now go through each one of them so that you can easily choose which one suits you best for completing a particular task in Excel.
If Statements
As the name suggests, IF something happens, then something else should happen as a result. However, if the thing does not happen, then nothing should change. Similar to the conditionals that you use in your own language to distinguish between conditions, the programming language uses the same logic to complete the same process – except in this case you are talking to a piece of software. This is the simplest of the logical codes, and it is certainly the first one that you should start with if you have not created a macro before. Even though there are other conditional logics for you to choose from, you can actually use the IF function to create any kind of conditional logic. Of course, for the more complex codes of conditional logic your IF code will look a lot longer than the conditional logic that you could have used to speed things up.
Else
This is a part of the code that you can add within an IF statement to give it more depth and complexity for what you want it to do. You will add this part of the code after the initial request for the IF code. For example, if you want to create a code that will tell Excel “If a number is 5 leave it, if the number is not 5 (else) clear the cell”. This is another versatile code that you can use however suits you best.