VBA Quotes in Strings: How to Include Double Quotes

VBA & macros · Updated November 22, 2026

To put a double quote inside a VBA string, double it: write "" inside the surrounding string literal. For example, "She said ""Hello.""" evaluates to She said "Hello.". You can also build a quote character with Chr$(34), which is handy when constructing text piece by piece.

How VBA handles quotation marks

In VBA, double quotation marks mark the beginning and end of a string literal. A string literal is text written directly in your code, such as "Good morning". Since the first and last quote already define the string’s boundary, VBA needs a special way to tell an intended quote character apart from those boundary marks: inside a string literal, two consecutive double quotes represent one quote in the resulting text.

This is different from languages that use a backslash to escape special characters. In VBA, a backslash does not escape a quotation mark. For example, "She said \"Hello\"" is not the VBA way to represent quoted speech; it can cause a compile error or produce an unintended result. Use doubled quotes instead.

The rule applies anywhere VBA expects a string literal, including assignments, message boxes, worksheet values, and comparisons. It does not change how quotation marks work in the VBA editor outside a string. For example, the quotation marks around a worksheet address in Range("A1") delimit the address text; they are not part of the address.

Put a quote inside a string literal

Double each quotation mark that should appear in the final text. The outermost quotes still start and end the literal; each doubled pair inside it becomes a single quote character when VBA runs the code.

Sub ShowQuotedText()
    Dim message As String

    ' Doubled quotes produce one quote in the displayed text.
    message = "She said ""Ready?"""
    MsgBox message
End Sub

The message box displays She said "Ready?". Notice that the code contains three quote marks at the end: two represent the closing quote shown in the message, and the last one ends the string literal. That cluster can look confusing at first, so it helps to read from left to right and identify which pairs are content and which mark the literal’s boundary.

Here are a few more examples of the same rule:

  • text = "A ""quoted"" word" produces A "quoted" word.
  • text = """" produces one double-quote character.
  • text = "No quote here" contains no quote character in its value; its two outer quotes only delimit the literal.

Use Chr$(34) to build a quote

The character code for a standard double quote is 34. VBA’s Chr$ function returns the character for a numeric code, so Chr$(34) returns a quote. This is useful when a string contains several quotes or when quotes are added around a value dynamically, rather than typed as part of a fixed literal.

Sub BuildQuotedMessage()
    Dim quoteMark As String
    Dim message As String

    ' Character 34 is the standard double quote.
    quoteMark = Chr$(34)
    message = "She said " & quoteMark & "Ready?" & quoteMark
    MsgBox message
End Sub

This displays the same result as the doubled-quote example. The & operator joins strings; it does not add a visible space unless one is included in one of the pieces. Chr$(34) is a function call, while Chr(34) is also commonly used in VBA. The dollar-sign form explicitly returns a String, which makes the intended type clear.

You can also use this technique to wrap a changing value in quotes. For example, set itemName to a cell’s text, then join a quote before and after it. This is often easier to read than a long literal with many adjacent quote marks. For one short, fixed phrase, however, doubled quotes are usually simpler.

Join strings with the ampersand operator

Use & when combining literal text, variables, and quote characters. It is the standard string-concatenation operator in VBA. Although VBA also permits + in some string expressions, & makes it clear that the operation is joining text. The plus sign can be ambiguous when values are numeric or can be converted to numbers, so it is generally a poor choice for assembling text.

Sub AddQuotesAroundName()
    Dim personName As String
    Dim quoteMark As String
    Dim result As String

    ' Save a copy of the workbook before running a macro.
    personName = "Mina"
    quoteMark = Chr$(34)
    result = quoteMark & personName & quoteMark
    MsgBox result
End Sub

The result is "Mina", including the quotation marks. If you want a space or punctuation, include it as a literal part: for example, "Name: " & quoteMark & personName & quoteMark produces Name: "Mina". Concatenation does not automatically add separators between the pieces.

When assembling text from a cell or another variable, check whether the value might be empty or contain its own quotation marks. VBA will join the characters as given; it will not automatically escape or remove quotes for you. That behavior is important when creating text for another system, such as a CSV file or a database command, because that destination may have its own escaping rules.

Write quoted text to an Excel cell

Assigning a VBA string to a cell uses the same quote rules as any other assignment. The quotes that delimit the literal in your code are not written to the cell; only the string’s contents are. To put visible quotes around a word in cell A1, double the inner quotes in the VBA literal:

Sub WriteQuotedTextToCell()
    Dim note As String

    ' Save a copy of the workbook before running a macro.
    note = "The status is ""Open""."
    ThisWorkbook.Worksheets(1).Range("A1").Value = note
End Sub

After the macro runs, A1 contains The status is "Open".. The assignment targets the first worksheet in the workbook containing the macro. For a real workbook, using a worksheet by name, such as Worksheets("Summary"), can be safer than relying on its position if sheets may be rearranged.

If the cell displays a formula instead of the text you expected, inspect the value assigned and the destination cell’s formatting. A string beginning with an equals sign may be interpreted as a formula when assigned to a cell in some circumstances. That is a separate issue from quote escaping. For ordinary text, the doubled-quote rule still determines which quote characters are in the VBA string.

Put a string across multiple code lines

A VBA string literal cannot simply continue onto the next code line by pressing Enter. To make a long expression easier to read, join separate string pieces with &. You can use the VBA line-continuation character, an underscore preceded by a space, to continue the statement on the next line.

Sub MakeLongMessage()
    Dim message As String

    ' The underscore continues this statement on the next code line.
    message = "This is a long " & _
              "string with a ""quoted"" phrase."
    MsgBox message
End Sub

The line break in the code is only for readability; the resulting message is one line. To include an actual line break in the string value, join the parts with vbCrLf (a carriage return and line feed), or use vbLf when a line feed alone is appropriate. For example, "First line" & vbCrLf & "Second line" contains a line break between the two phrases. In a worksheet cell, turn on Wrap Text if you want the line break to be visible across multiple lines.

Common quote-related mistakes

Quote problems are often syntax problems: a missing closing quote, an extra quote, or a quote that was not doubled inside a literal. If VBA highlights a line with a compile error, count the quote marks and check whether each intended quote in the output is represented by a pair in the code. The closing quote of the whole literal must still be present after the content.

  • Using backslash escaping: VBA does not use \" to represent a quote. Use doubled quotation marks or Chr$(34).
  • Confusing code quotes with output quotes: The outer pair in "Hello" is not part of the resulting text. Double quotes inside the literal are needed only when a quote should appear in the value.
  • Using smart quotes: Curly characters such as “ and ” are not interchangeable with the straight quote character used to delimit VBA strings. Type straight quotes in code.
  • Using a plus sign for text: Prefer & for joining strings, especially when variables could contain numbers.
  • Expecting quotes to be added automatically: A cell value or variable is joined exactly as supplied. Add quote characters explicitly if the final text needs them.

Apostrophes are different from double quotes. They can appear inside a double-quoted string without being doubled: "Don't stop" is valid and contains the apostrophe. Outside a string, an apostrophe starts a VBA comment, which is why moving an apostrophe outside the quotation marks can change how the code is interpreted.

Choose the clearest method for the job

For a short, fixed string, doubling the quote is usually the clearest choice because the entire result is visible in one expression. If the text has many embedded quotes, a quote variable made with Chr$(34) may be easier to scan. For a value that changes at runtime, concatenate the quote character around the variable with &. Both approaches create the same ordinary quote character; the choice is about readability and maintainability.

Think about the destination too. A string sent to a message box or worksheet cell only needs to be valid VBA text. A string sent to another format may need additional escaping or encoding. CSV files, JSON text, SQL statements, and HTML each have rules of their own; doubling quotes in VBA only tells VBA how to parse its own string literal. It does not guarantee that the resulting text is valid for those other formats.

For instance, if a variable contains a person’s name and the name itself includes a quote, simply wrapping it in quotes may produce ambiguous output. A CSV field has a specific rule for representing quotes inside quoted fields, while SQL uses rules that depend on the database and how the command is built. Do not assume VBA’s doubled-quote syntax performs that second layer of escaping. Use the destination format’s documented method, and prefer parameters over constructing database commands from raw text.

Run and inspect the example safely

In Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor. In the editor, choose Insert > Module, paste a complete Sub procedure into the module, and run it with the cursor inside that procedure by pressing F5. To inspect a value without a message box, use Debug.Print message and view the Immediate window in the editor. These tools help distinguish a compile-time quote error from a string whose contents are simply not what you expected.

On a Mac, Option+F11 opens the Visual Basic Editor on many keyboards; you may need to hold Fn as well, depending on the keyboard’s function-key settings. The VBA editor’s menus and available features can differ somewhat from Windows. Before running any macro that changes a workbook, save a separate copy. Macro actions generally cannot be undone with Ctrl+Z on Windows; on Mac the equivalent Undo shortcut is Command+Z, but it does not reverse VBA macro actions either.

Frequently Asked Questions

How do I add double quotes inside a VBA string?
Type two consecutive double quotes where you want one quote in the output. For example, "She said ""Hi""" produces She said "Hi".

Does a backslash escape quotes in VBA?
No. A backslash does not escape a quotation mark in a VBA string. Double the quote inside the literal, or use Chr$(34) to create the quote character.

What does Chr(34) return in VBA?
Chr(34) returns the standard double-quote character. Chr$(34) returns it as a String, so it can be joined to other text with &.

How can I put quotes around a variable?
Join a quote before and after the variable: create a quote character with Chr$(34), then concatenate it with the value using &. The variable’s contents are not changed by this operation.

Can a VBA string literal continue on the next line?
Not by inserting a plain line break in the middle of the literal. Join separate string pieces with & and use a space followed by an underscore to continue the statement, or put an actual line break in the value with vbCrLf.

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.