Wauvel

Excel like a finance pro.

← The library

VBA · Syntax

Line continuation

A space and underscore lets a statement continue on the next line.

OccasionalDifficulty 1000 · Capable
Practice · 2 questions →

When to use it

A space followed by an underscore at the end of a line continues the statement on the next line, keeping long calls readable.

The code

Code
MsgBox "Hello " & _
  "world"

Worked examples

  • Split a string

    MsgBox "Hello " & _ "world" One statement across two lines

    Long strings.

  • Long method calls

    Range("A1:D100").Sort Key1:=Range("B1"), _ Order1:=xlDescending, Header:=xlYes A long method call laid out one argument per line

    Readable calls.

  • Long conditions

    If x > 0 And _ y > 0 Then A condition split across lines

    Complex conditions.

Worth knowing

  • There is a limit of 24 continuations per statement.
  • You cannot continue inside a string literal; close it, add &, then continue.
  • Indent continued lines so the structure is visible.

Where it goes wrong

  • The underscore must be preceded by a space or it is a syntax error.
  • A continuation at the very end of a procedure confuses the compiler.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.