Skip to Main Content

Double Quote Characters in String Variables

Written by Rod Wing.

As you may know, when assigning a text string to a string variable the text is enclosed in “double quotes”. If you need to have a double quote character in the string simply precede the double quote character with another double quote character.

Sub QuoteMacro()

Dim strQuote As String

strQuote = “This string has no double quotes”

strQuote = “This string has “”double quotes“” in the middle”

strQuote = “””This string has a double quote at the beginning”

strQuote = ”This string has a double quote at the end”””

strQuote = “””This string has double quotes on both ends”””

‘The following string contains a single double quote character

strQuote = “”””

End Sub

Last Month’s VBA Tip – Save User Inputs as Default Settings

One comment on “Double Quote Characters in String Variables

Leave a Reply

Your email address will not be published. Required fields are marked *