Select Page

Excel Video 438 introduces case statements, which are a more concise and easier to read way to express multiple options in VBA. Notice how the Case statement starts with Select Case and ends with End Select and how the Case statement fits inside the loop so that each row is evaluated as part of the Case statement. The other thing to know about a Case statement is that VBA takes the first case that evaluates as true and exits the statement. In other words, if the first case is true, VBA won’t look at or act on future cases in the same statement.
I’m going to wrap up our discussion of macros and VBA with two examples of user defined functions. A user defined function is a custom function that works like built-in Excel functions, such as SUM or COUNT. We’ll work through the first user defined function in the next Excel Video. I look forward to seeing you then.