Excel Guides

Continuing Macro Lines in Excel

You can continue macro lines in Excel by using the underscore character. When you use the underscore character, everything that follows on that line is considered to be part of the same statement. This can be useful when you need to break up a long statement into multiple lines for readability.

For example, let's say you have a macro that looks like this:

Sub MyMacro()
    Range("A1").Value = "Hello"
    Range("A2").Value = "World"
End Sub

If you wanted to break this macro up into multiple lines for readability, you could do so by using the underscore character:

Sub MyMacro()
    Range("A1").Value = "Hello" _ 
        Range("A2").Value = "World" 
End Sub

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.