Writing Executable Statements
An executable statement initiates action. It can execute a method or function, and it can loop or branch through blocks of code. Executable statements often contain mathematical or conditional operators.
The following example uses a For Each...Next statement to iterate through each cell in a range named
The If...Then...Else statement in the example checks the value of the cell. If the value is greater than 33, the With statement sets the Bold and Italic properties of the Font object for that cell. If...Then...Else statements end with End If.
The With statement can save typing because the statements it contains are automatically executed on the object following the With keyword.
The Next statement calls the next cell in the collection of cells contained in
The MsgBox function (which displays a built-in Visual Basic dialog box) displays a message indicating that the Sub procedure has finished running.