Importing external data into clean databases often fails because "smart" (curly) quotes break critical syntax. While standard funding sources for IT modernization focus on macro-level system integrations rather than these micro-level formatting hurdles, data analysts require immediate, cost-effective remedies. Fortunately, masterfully structuring your spreadsheets grants complete automation over character sanitization, saving hours of manual correction. As a key stipulation, this method specifically targets Unicode characters 147 and 148, so source encoding variations must be monitored. Implementing nested SUBSTITUTE functions to convert curly quotes to straight quotes serves as a proven blueprint. Below, we examine the exact formula syntax and step-by-step setup.
If you have ever copy-pasted data from Microsoft Word, a PDF document, an email, or a web page into Excel, you have likely encountered the headache of "smart quotes." Also known as curly quotes (“ ” and ‘ '), these stylized punctuation marks look great in prose but are a complete nightmare in data management, programming, and Excel formulas.
Excel formulas, CSV parsers, database engines, and programming languages do not recognize smart quotes as valid text delimiters. To Excel, only the standard, straight double quotes (") and straight single quotes (') can define text strings. If your data contains smart quotes, your lookup formulas might fail, your data imports might break, and your SQL queries will throw syntax errors. Fortunately, you can clean these troublesome characters using Excel's SUBSTITUTE function. This guide will walk you through building a robust, reusable formula to purge smart quotes from your datasets.
To clean data in Excel, the SUBSTITUTE function is your primary tool. It searches a specific text string for a defined character or substring and replaces it with another. The syntax is straightforward:
=SUBSTITUTE(text, old_text, new_text, [instance_num])
old_text to replace. If omitted, every occurrence is replaced.Before building the formula, there is a technical hurdle to address: how to write a straight double quote inside an Excel formula. Because Excel uses double quotes to start and end text strings, you cannot simply write " inside your formula to represent a double quote. Excel will think you are trying to open or close a string, resulting in a formula error.
There are two ways to solve this:
"""". The outer two quotes tell Excel this is a text string, and the inner two tell Excel to treat it as a literal double quote.CHAR function. Every character on your computer has a corresponding character code. The standard straight double quote is code 34, and the straight single quote is code 39. Therefore, CHAR(34) returns a straight double quote, and CHAR(39) returns a straight single quote.To completely clean a cell, we must address four distinct smart quote characters:
“)”)‘)')We can clean all of these by nesting multiple SUBSTITUTE functions inside one another. Let's build this step-by-step, assuming the dirty text is in cell A2.
First, we nest two SUBSTITUTE functions to target both the opening and closing double curly quotes, replacing them with a straight double quote (using CHAR(34)):
=SUBSTITUTE(SUBSTITUTE(A2, "“", CHAR(34)), "”", CHAR(34))
Next, we nest two more SUBSTITUTE functions around our existing formula to target the single curly quotes, replacing them with a straight single quote (using CHAR(39)):
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, "“", CHAR(34)), "”", CHAR(34)), "‘", CHAR(39)), "'", CHAR(39))
This single, nested formula systematically scans the text in cell A2 and replaces all four variations of curly quotes with their standard, data-friendly straight equivalents.
While the formula above works perfectly, typing or copy-pasting curly quotes directly into the Excel formula bar can sometimes fail. Depending on your system language, regional settings, or keyboard layouts, Excel may not interpret the pasted curly quote correctly.
To make your formula bulletproof across all devices and locales, you can use the exact character codes for the smart quotes themselves. Here is the translation table of the character codes involved:
| Character Name | Visual Symbol | ASCII/ANSI Code | Straight Replacement Code |
|---|---|---|---|
| Left Single Curly Quote | ‘ | CHAR(145) |
CHAR(39) ( ' ) |
| Right Single Curly Quote | ' | CHAR(146) |
CHAR(39) ( ' ) |
| Left Double Curly Quote | “ | CHAR(147) |
CHAR(34) ( " ) |
| Right Double Curly Quote | ” | CHAR(148) |
CHAR(34) ( " ) |
Using these codes, we can rewrite our nested formula to be completely immune to copy-paste issues and keyboard variations:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, CHAR(147), CHAR(34)), CHAR(148), CHAR(34)), CHAR(145), CHAR(39)), CHAR(146), CHAR(39))
This formula requires no hardcoded curly quotes. It is highly readable for advanced Excel users and can be safely shared across global teams without risk of breaking.
If you are working with millions of rows of data, writing complex formulas can slow down your workbook's performance. For large-scale data transformation, Power Query is a much faster and more sustainable solution.
To replace smart quotes using Power Query, follow these steps:
“). In the "Replace With" field, type a standard double quote ("). Click OK.”) and the single curly quotes (‘ and ').Cleaning your data is great, but preventing the issue at the source is even better. Excel actually has an auto-correct setting that converts straight quotes to smart quotes automatically as you type. If you want to disable this feature globally across Microsoft Office, follow these steps:
Smart quotes can cause silent, frustrating errors in your data pipelines. By utilizing the nested SUBSTITUTE function with robust CHAR codes, you can instantly cleanse your text, ensuring absolute compatibility with external applications, databases, and core Excel operations. For persistent projects, adjusting your Microsoft Office AutoCorrect preferences or utilizing Power Query can save you hours of troubleshooting down the line.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.