Office tutorials

Select CASE statement in Excel VBA

SELECT CASE instruction – introduction

Another instruction next to IF THEN ELSE used in the decision making process by our program is the SELECT CASE VBA statement . The instruction checks whether the instruction entered in the instructions is in accordance with the conditions stated in the instructions. On this basis, one scenario is chosen in our decision-making process. After selecting the scenario, the action stored in the block is executedCase scenario and the statement ends its operation. The Model CASE VBA statement model looks like this:

An example of the use of the Select CASE VBA instruction

For starters, let’s take a simple example. We want the word number to display its verbal description after entering the month number in the InputBox window . So for January it will be the number 1, for February 2, etc. In case when the value entered will go beyond the range 1-12, or the entered value will not be an integer, we will receive a message asking for the correct value.

 

Tasks (You can enter the solution in a comment)

  1. Based on the course section regarding the IF THEN ELSE instructions,  item 3. build an analogous example using the Select CASE statement.
  2. Based on the example in this chapter, write a program which after entering the number representing the day of the week will return its verbal version.

1 comment

    • 8be on June 26, 2018 at 12:10 pm

    Reply

    excellent post, very informative. I’m wondering why the other specialists of this sector do not realize
    this. You should proceed your writing. I’m confident,
    you’ve a great readers’ base already!

Leave a Reply

Your email address will not be published.