Search notes:

VBA: line continuation

In VBA, a statement typically extends to the end of line. In order to span a statement over multiple lines, the unserscore (_) must be used. In VBA's terminology, this character is also referred to as line continuation character.
The underscore must be set apart from its preceding character or symbol by at least one whitespace.
There's in arbitrary limit of 25 lines that can be continued. Trying to exceed this limit results in a Too many line continuations error.

Simple demonstration of line continuation

The following simple demonstration code spreads a calculation over three lines, possibly for better visual clarity:
option explicit

sub main() ' {

    debug.print  "The result of the summation is: " _
       4 + 5 + 9 + 10 + _
       3 + 1 + 8 +  7

end sub ' }
Github repository about-VBA, path: /line-continuation.bas

See also

Multiple statements can be put into one line by separating them by a colon (:).
The line continuation character of cmd.exe is the the caret (^).

Index