VBA offers several ways of controlling the execution of a procedure. Some of these will
be discussed here.
If-Then-Else Structure
We begin our discussion of program flow control with a VBA statement structure that
will look familiar because of the IF worksheet function of Excel. This VBA structure
is known as the If-Thenstructure or conditionalstructure. The structure uses two
keywords If and Then to enclose a condition that you specify. The structure looks as
follows:
If condition Then Statement
The VBA checks for the condition. If it is true it executes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.