April 30, 2012 / Updated: October 24, 2021 / Lena Shore
Filed under: Tutorials
This tip is going to be mostly helpful to people who working with databases. But, if you work with Excel and find yourself needing to deal with repetitive formatting, you might also appreciate the technique.
When working with CSV files you may need to add quotes to either side of a cell’s contents in order to upload them properly to your database. You can easily find yourself working with an Excel file from a workmate that needs to be formatted.
You got this:
But really need this:
This can be a big damn deal if you have hundreds of fields. No one wants to add this by hand. Fortunately, the solution is a snap! It all has to do with applying specific formatting to your cells.
- Highlight the cells you want to add the quotes.
- Go to Format –> Cells –> Custom
- Copy/Paste the following into the Type field: ”@”
- Click “okay”
- Be happy you didn’t do it all by hand.
NOTE: It’s always a good idea to open your file in a text editor to double-check your CSV export. Sometimes you need to do a little find/replace action to get your file picture perfect.
Lena is a full-time freelancer and nerd that specializes in web development, graphic design, and illustration. She enjoys building things, learning new things, pursuing creative endeavors, and giving free advice.
Within Excel formulas, double quotes are used to denote the start and end of a text string. Therefore, the obvious question is: how to add double quotes in Excel?
Look at the following formula as an example:
="Here is some sample text"
The double quotes are at the start and end of the text string. But what if we want the text string to include double quotes, how do we do that? We can’t use the following:
="Here is some "sample" text"
If we try this, it will result in an error message: “There is a problem with this formula….”
Excel doesn’t provide a solution here; it just tells us there is an error.
We’ll cover the best options to solve this problem in the remainder of this post.
Using single quotes instead
This first solution is almost too simple to mention. But why go for a more complicated option if this meets your requirements?
If we want to indicate that something is a special name, then maybe single quotes will be a suitable alternative.
="Here is some 'sample' text"
Single quotes have their own special meaning in Excel, but when enclosed within double quotes, they are treated as text
Many times, this won’t be a good solution. For example, if we are using the shorthand method for noting feet and inches, we must use the single-quote and double-quote characters (e.g., 6’2″ is shorthand for 6 feet 2 inches). In this circumstance, this simple solution won’t work, so let’s look at some alternatives.
Double quotes using an escape double quote
Using an additional double quote character serves as an escape character. Take a look at the following formula:
="Here is some ""sample"" text"
By using two “ characters next to each other, the first is an escape double quote. this tells Excel to recognize the second “ as text and ignore the first.
In our example, if the word sample were in cell A1, we could concatenate the string using the & symbol. But we would also need to add additional escape double quotes to indicate the start and end of each text string.
="Here is some """ & A1 & """ text"
In the formula above:
- Blue: the start or end of each text string
- Red: the double quote escape character
- : the displayed double-quote character
It works, but it’s starting to become harder to read.
Double quotes with CHAR function
The third solution is to use the CHAR function.
The escape character method demonstrated above can start to become a bit confusing; there are just too many quotation marks to easily understand what’s going on. This is where the CHAR function may be a better option.
The CHAR function returns a specific character based on a code number from the operating system’s character set. In a standard character set, CHAR(34) is the double-quote character.
Let’s look at this using an example:
="Here is some "&CHAR(34)&"sample"&CHAR(34)&" text"
We still need double quotes to start and end the text strings, but we can use the & character and CHAR(34) to add double quotes into the result of our formula.
Add double quotes automatically with custom number format
The fourth option is quite a niche solution. It is only relevant where we wish an entire text string to be enclosed on double quotes. We can create a custom number format that automatically provides the appearance of double quotes.
- Click Home > Number (section) > Drop-down > Select More Number Formats… (or press Ctrl + 1) to open the format cells dialog box.
- Select the Number tab, click Custom
- In the Type box enter: ”@”
- Click OK to apply the number format.
If you enter any text into a cell with the number format applied, it automatically appears in double quotes.
NOTE: This does not add double quotes to the value, but formats the cell to give the appearance of double quotes.
Conclusion
Well, that’s it. We’ve looked at four options you can choose to insert double quotes into an Excel formula. But which is the best?
Like most things in Excel, there is no “best”. So, it comes down to your personal preferences. Whichever is the easiest for you to use, and meets your requirements, do that.
Related posts:
- CHAR function in Excel
- Change number format based on a cell value
About the author
Hey, I’m Mark, and I run Excel Off The Grid.
My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn’t until I was 35 that my journey really began.
In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).
Do you need help adapting this post to your needs?
I’m guessing the examples in this post don’t exactly match your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.
But, if you’re still struggling you should:
- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
- Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise. List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.
What next?
Don’t go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts:
In this Excel lesson you will teach yourself how to deal with single quote issues.
Table of content:
How to quote a quote in Excel formula?
Using char 39
Using HTML code for a single quote
Using strings concatenation
Using ASCII code
Using formula bar
Using TEXT function
Using REPT function
In Excel there is a problem that ‘yourtext’ (text inside single quotes) displays without leading single quote. There is an easy way to deal with this issue.
- Right click your cell.
- Choose Format Cells to format a data type for the cell.
- Click Custom Category.
- Write down ‘@ (single quote and at) as a type.
That’s it. Your single quotes are displaying correctly since now.
How to quote a quote in Excel formula?
Excel formulas are used to do some simple calculations, to drive results using other cell values and sometimes we use some alphabetical strings in excel formulas which involve quotes : «.
E.g When the formula contain a string like :
a. My height is 70 «
b. My height is 70 inches.
Now statement b can easily be inserted in an excel formula like = «My height is 70 inches.»
But for statement a we cannot write like: =» My height is 70 » «
It will return formula errors:
So whenever we have quotes in a formula we have to understand that we have to escape the double quotes with double apostrophes to let Excel read it properly.
So the correct value: = » My height is 70 «» «
Using char 39
Another way to do this is using CHAR(39) for single quotes. The CHAR function allows you to enter a specific character code and display the corresponding character in a cell.
Like we used quotes before apostrophes in previous example, here we are using char(39) instead of writing the quotes:
=» My height is 70 » & CHAR(39)
And the result will be same: My height is 70 ‘
The code for a double quote is 34, so you can use the following formula to display a double quote:
=CHAR(34) & «Your text here» & CHAR(34)
Using HTML code for a single quote
There is another method you can use to display a single quote in an Excel cell, which is to use the HTML code for a single quote, which is '. To display a single quote, you can use the following formula:
=»Your text here ' single quote«
For example, if you want to display the text «Don’t stop now» in a cell, you would enter the following formula:
=«Don't stop now»
The result in the cell will be:
Don’t stop now
Using strings concatenation
Another method to display a single quote in an Excel cell is to use a formula that concatenates text strings. You can use the ampersand & operator to concatenate text strings in a formula. To display a single quote in a formula, you can use two double quotes together «» to represent a single quote.
For example, if you want to display the text «Don’t stop now» in a cell, you would enter the following formula:
=«Don» & «»«» & «t stop now»
The result in the cell will be:
Don‘t stop now
You can also use the concatenation formula to display other special characters, such as double quotes or new lines, in an Excel cell.
Using ASCII code
Another method to display a single quote in an Excel cell is to use the ASCII code for a single quote, which is 39. You can use the CODE function to return the ASCII code for a character, and the CHAR function to return the character for a given ASCII code. To display a single quote, you can use the following formula:
=CHAR(CODE(«‘»)) & «Your text here» & CHAR(CODE(«‘»))
For example, if you want to display the text «Don’t stop now» in a cell, you would enter the following formula:
=CHAR(CODE(«‘»)) & «Don’t stop now» & CHAR(CODE(«‘»))
The result in the cell will be:
Don‘t stop now
Using formula bar
Another method to display a single quote in an Excel cell is to use the Excel formula bar to enter the text. To do this, you can simply enter the text in the formula bar, rather than in the cell itself. To enter a single quote, you can press the single quote key on your keyboard.
For example, if you want to display the text «Don’t stop now» in a cell, you would do the following:
- Select the cell in which you want to display the text.
- Click on the formula bar above the worksheet to activate it.
- Type the text Don’t stop now in the formula bar.
- Press the Enter key to confirm the entry.
Using TEXT function
Another method to display a single quote in an Excel cell is to use the formula text function. The text function allows you to format a number as text. To display a single quote in a formula, you can use the text function to format a blank text string as text.
For example, if you want to display the text «Don’t stop now» in a cell, you would enter the following formula:
=TEXT(«»,«Don'»»t stop now»)
You can also use the text function to format numbers as text, and to apply custom formatting to numbers. The text function is useful for preventing unwanted changes to your data, such as the removal of leading zeros or the conversion of numbers to dates.
Using REPT function
Another method to display a single quote in an Excel cell is to use the REPT function. The REPT function allows you to repeat a character or a string a specified number of times. To display a single quote, you can use the REPT function to repeat a single quote character.
For example, if you want to display the text «Don’t stop now» in a cell, you would enter the following formula:
=«Don» & REPT(«‘»,1) & «t stop now»
In conclusion, there are several methods for displaying a single quote in an Excel cell, including:
- Using the CHAR function with the code for a single quote (39).
- Using the formula bar to enter the text.
- Using the TEXT function to format a number or text as text.
- Using the REPT function to repeat a single quote character.
- Using the HTML code for a single quote (
'
). - Using the concatenation operator
&
to combine two or more strings.
Each of these methods has its own advantages and limitations, and the best method will depend on your specific needs and requirements. Regardless of the method you choose, the key is to understand how to properly enter the formula or text in the cell to ensure that the single quote is displayed correctly.
This Excel tutorial explains how to put double quotes in a text formula in Excel.
Placing a double quote inside of a formula in Excel might seem a bit tricky. Normally, when you write a formula in Excel, you enclose any string values in double quotes. So it might not seem obvious how you can put a double quote in your formula without Excel returning formula errors.
Let’s start by looking at a formula that uses double quotes to separate string values in the formula. This will help you better understand the challenge of how to use double quotes in an Excel formula.
For example:
In this example, we have a formula in cell C4 that uses double quotes to enclose string values as follows:
=A4 & " feet is equal to 24 inches exactly"
This formula would output the following text value:
2 feet is equal to 24 inches exactly
Now, how could we replace the word inches in this example with a double quote so that the double quote is displayed in the formula result?
There are 2 ways that we can insert a double quote in a formula. The first method is to escape the double quote and the second method is to use the CHAR function. Let’s explore both of these options.
Escape the Double Quote
Inserting a double quote is actually quite easy to do. If you escape your double quote with an additional double quote, Excel will treat the escaped double quote as a literal value instead of treating the double quote as the start or end of a string value.
For example:
Here, we have changed our formula in cell C4 to insert one double quote by entering two double quotes in the formula:
=A4 & " feet is equal to 24"" exactly"
This formula would output the following text value:
2 feet is equal to 24" exactly
By placing two double quotes, Excel knows that we are escaping the second double quote. Now our formula will display a double quote in the formula results. The double quote is now treated as a literal.
Use the CHAR function
You can also insert a double quote in an Excel formula using the CHAR function.
The CHAR function takes the ASCII value and returns the corresponding character value. The ASCII value for a double quote is 34. Let’s show you show we could modify our example above and use the CHAR function with an ASCII value of 34 to insert the double quote in our formula.
For example:
Here, we have changed our formula in cell C4 to insert a double quote by using the CHAR function in the formula:
=A4 & " feet is equal to 24" & CHAR(34) & " exactly"
This formula would output the following text value:
2 feet is equal to 24" exactly
Now when the formula encounters the CHAR(34), it returns a double quote value.
As you can see, there are different ways to insert a double quote within a formula in Excel. It is up to you to choose which method you prefer.
Explanation
To include double quotes inside a formula, you can use additional double quotes as escape characters. By escaping a character, you are telling Excel to treat the » character as literal text. You’ll also need to include double quotes wherever you would normally in a formula.
For example, if cell A1 contains the text: The Graduate and you want wrap that text inside double quotes («»), you can use this formula:
=""""&A1&""""
Because the text on either side of A1 consists of only of a double quote, you need «»»» . The outer quotes (1 & 4) tell Excel this is text, the 2nd quote tells Excel to escape the next character, and the 3rd quote is displayed.
If you want to add the movie to other text to create, you can concatenate the movie title inside double quotes with a formula like this:
="The 1960's movie """ &A1&""" is famous"
The result: The 1960’s movie «The Graduate» is famous
Working with extra double quotes can get confusing fast, so another way to do the same thing is to use the CHAR function with the number 34:
="The 1960's movie "&CHAR(34)&A1&CHAR(34)&" is famous"
In this case, CHAR(34) returns the double quote character («) which is included in the result as literal text.
CHAR is handy for adding other text that is hard to work with in a formula as well. You can use CHAR(10) to insert a line break character into a formula on Windows. On a Mac, use CHAR(13):
=CHAR(10) // win line break
=CHAR(13) // mac line break
Microsoft Excel uses double quotation marks to signify text within formulas. When it sees these marks, it uses the text and discards the quotes. Typing quotation marks directly into a cell is not an issue because Excel automatically recognizes that you are entering text and therefore keeps the quotation marks. However, when typing formulas, you need to use a special character formula to output quotation marks.
-
Open Microsoft Excel.
-
Type quotation marks in an Excel cell without adding an equal sign. For example, if you entered the following text, it would appear exactly as you entered it:
«text»
However, if you entered an equal sign before it, you would only get the text inside the quotation marks.
-
Use «CHAR(34)» within formulas where you need to output quotation marks. For example, to add quotes around the text in cell A1, you would type «=CHAR(34)&A1&CHAR(34)» in an empty cell.