VBA MsgBox Multiple Lines: Line Breaks and Examples

VBA & macros · Updated November 18, 2026

To show multiple lines in a VBA MsgBox, join the text with the built-in line-break constant vbCrLf. For example, MsgBox "First line" & vbCrLf & "Second line" displays the two sentences on separate lines.

How line breaks work in a MsgBox

A MsgBox displays a prompt string: the text you pass as its first argument. A VBA string can contain a line-break character, so you can build a prompt from several parts and place a break between them. The ampersand (&) joins those parts together; vbCrLf supplies a Windows-style carriage return followed by a line feed.

The general pattern is:

firstText & vbCrLf & secondText

Each additional vbCrLf starts another line. You can put the break between fixed pieces of text, between a label and a value, or before a short instruction. A break is not the same as a space: it moves the following text to a new line. The message box may also wrap long lines automatically according to its available width, but explicit breaks let you decide where important lines begin.

In the VBA editor, enter code in a standard module or another appropriate code module, then run the procedure. In Excel for Microsoft 365 on Windows, you can open the editor with Alt+F11, or use Developer > Visual Basic. On a Mac, the editor shortcut depends on the keyboard and function-key settings; Option+F11 or Fn+Option+F11 may be needed. A MsgBox is a VBA feature, not an Excel worksheet formula, so it runs from a macro rather than from a cell.

A simple two-line example

This complete procedure shows the shortest practical pattern. Before running any macro, save a copy of the workbook: VBA macros cannot be undone with Ctrl+Z, even though this example only displays a message.

Sub ShowTwoLines()
    ' Display two sentences on separate lines.
    MsgBox "The report is ready." & vbCrLf & _
           "Check the totals before sending it.", vbInformation, "Report status"
End Sub

The first argument is the joined prompt. The optional second argument, vbInformation, adds an information icon, and the third argument sets the title bar to Report status. If you do not need an icon or a custom title, you can omit those optional arguments. The line-continuation characters, a space followed by an underscore at the end of the first code line, let VBA continue one statement on the next physical line; they do not create a new line in the message.

Put several lines in a readable prompt

For longer messages, make each piece of text clear in the code and insert a break wherever a new line should appear. The following example creates a three-line reminder:

Sub ShowReminder()
    Dim promptText As String

    ' Build a prompt with a heading and two details.
    promptText = "Before you close the workbook:" & vbCrLf & _
                 "Save your changes." & vbCrLf & _
                 "Update the date in the summary."

    MsgBox promptText, vbExclamation, "Reminder"
End Sub

Here, the variable promptText holds the complete message before it is displayed. Storing a longer prompt in a variable is optional, but it can make the procedure easier to read, edit, and debug. You can also put all of the joined text directly inside the MsgBox call. Either approach produces the same line breaks.

Use an intentional structure rather than adding breaks after every few words. For example, a short heading followed by separate details is easier to scan than one long paragraph split into arbitrary fragments. Remember that the message box has limited space: a very long prompt can become awkward to read, and users must dismiss the dialog before returning to the workbook.

Combine line breaks with changing values

A prompt can mix fixed wording with values from variables. Convert numbers to strings when joining them into text so the intended result is unambiguous. This example displays a row number and a status on separate lines:

Sub ShowRowStatus()
    Dim rowNumber As Long
    Dim statusText As String
    Dim promptText As String

    ' Example values; replace these with values from your workbook.
    rowNumber = 12
    statusText = "Needs review"

    promptText = "Row: " & CStr(rowNumber) & vbCrLf & _
                 "Status: " & statusText

    MsgBox promptText, vbInformation, "Check required"
End Sub

In this example, the displayed prompt is Row: 12 on the first line and Status: Needs review on the second. CStr converts the numeric row number to text for concatenation. For a value taken from a worksheet, assign the cell value to a suitably declared variable or convert it as needed, then add vbCrLf between the pieces that should appear on separate lines. If a value might be empty, consider whether the label should still appear or whether the message should use a fallback such as Not specified.

Choose vbCrLf, vbNewLine, or Chr

For ordinary Excel VBA on Windows, vbCrLf is the clearest and most familiar choice for a new line. VBA also provides vbNewLine, which represents the platform-appropriate newline, and the equivalent character expression Chr(13) & Chr(10) on Windows. If a macro needs to be usable across platforms, vbNewLine is a reasonable choice to express the intention of a platform newline; in code written specifically for Windows, vbCrLf is explicit and easy for other VBA readers to recognize.

These choices are alternatives; do not combine them at one break. For example, adding vbCrLf & vbNewLine at the same position may create extra spacing rather than a single clean break. You can use the same chosen constant more than once when a prompt needs three or more lines. Chr(13) and Chr(10) refer to character codes, so using the named constant usually makes the code easier to understand and maintain.

Use buttons and capture the user’s answer

Line breaks affect the prompt text, not the buttons or the meaning of the return value. To ask a yes-or-no question, pass a button option and store the result as a VbMsgBoxResult. The prompt can still use several lines:

Sub ConfirmUpdate()
    Dim answer As VbMsgBoxResult
    Dim promptText As String

    ' Ask a question with the context on a separate line.
    promptText = "Update the summary now?" & vbCrLf & _
                 "This changes the current workbook."

    answer = MsgBox(promptText, vbYesNo + vbQuestion, "Confirm update")

    If answer = vbYes Then
        MsgBox "The update was confirmed.", vbInformation, "Confirmed"
    End If
End Sub

The first message gives the user context and offers Yes and No buttons. The answer is compared with vbYes; it is not the text shown in the dialog. Add button and icon constants when they improve the decision, but keep the prompt itself focused. A multi-line message is not a substitute for explaining what an action will change.

Common line-break problems and fixes

  • The text stays on one line. Check that vbCrLf is inside the prompt expression and joined to the surrounding text with &. A comma separates MsgBox arguments; it does not insert a line break.
  • You see the characters vbCrLf. This can happen if the constant is placed inside quotation marks as literal text, such as "vbCrLf". Use the constant outside the quotes: "First" & vbCrLf & "Second".
  • You get a compile error on a long statement. A VBA line continuation must be a space followed by an underscore at the end of the continued line. Do not put a comment after the underscore. Alternatively, assign shorter pieces to a string variable on separate statements.
  • The message has an unexpected blank line. Look for two break constants in succession, or for a break at the start or end of the prompt. Remove the extra constant if you want adjacent lines instead.
  • The prompt looks crowded despite the breaks. Shorten the wording or split a long detail into smaller parts. A dialog may wrap a long line on its own, so the displayed layout can vary with text length and dialog width.

Also use & to join text. The plus sign can sometimes concatenate strings in VBA, but it can also perform numeric addition or trigger type-coercion behavior. The ampersand clearly signals that you are building text, which reduces surprises when one part contains a number or another data type.

When a MsgBox is not the right display

A MsgBox is useful for a brief alert, confirmation, or small amount of information that needs the user’s attention. It is modal: while it is open, the user must respond to it before continuing to work in the workbook. That makes it a poor place for a long report, a list of many records, or instructions users may need to consult while working.

For information that should remain visible or be copied, write it to a worksheet, show it in a UserForm, or use a status-bar message for a short, non-blocking update. A UserForm takes more setup but can present multiple controls and longer text. A worksheet is often better when the reader needs to review, print, or filter the information later. These alternatives do not change how vbCrLf works in a MsgBox; they address whether a dialog is the right interface for the amount and purpose of the content.

Frequently Asked Questions

How do I put two lines in a VBA MsgBox?
Join the two text strings with vbCrLf, such as MsgBox "First line" & vbCrLf & "Second line". Add another vbCrLf for each additional line break.

Can I use vbNewLine instead of vbCrLf?
Yes. vbNewLine represents a platform-appropriate newline, while vbCrLf explicitly represents the carriage-return/line-feed pair commonly used on Windows. For Windows-only Excel VBA, either is suitable; choose one consistently.

Why does my MsgBox show vbCrLf as text?
It is probably inside quotation marks. Quoted characters are treated as literal prompt text. Put vbCrLf outside the quotes and concatenate it with &.

Can a MsgBox show more than two lines?
Yes. Join as many prompt sections as are practical, with a line-break constant between each section. Keep the message concise because a MsgBox is a small dialog and blocks interaction until dismissed.

Can I make a new line without concatenating strings?
You can build the prompt in a variable with multiple assignments, adding vbCrLf where needed, then pass that variable to MsgBox. The line break still has to be part of the final prompt string.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.