To remove every ordinary space from one Excel cell, enter =SUBSTITUTE(A1," ","") in a nearby blank cell, replacing A1 with the cell you want to clean. The result removes spaces between words as well as at the beginning or end. If you only want to remove extra spaces while keeping one space between words, use =TRIM(A1) instead. Then copy the result and paste it back as a value if you need to replace the original cell.
What You’ll Need
- Microsoft Excel for Microsoft 365 on Windows, or Excel for Mac or the web. The formulas below work in these versions.
- The cell containing the text or value you want to clean, plus a blank nearby cell for the formula result.
- A copy of the original value if it is important. Formulas are reversible while the original remains, but pasting over it replaces that original content.
Step-by-Step
- Choose exactly what should count as a space. Decide whether you want to remove every ordinary space, such as the gap in First Last, or just clean extra spaces at the start, end, or between words. Removing all spaces changes First Last to FirstLast, which may be right for an ID or code but usually is not right for a person’s name or a sentence.
- Locate the cell and leave it unchanged for now. For example, suppose the text to clean is in A1. Click a blank cell beside it, such as B1, rather than typing a formula into A1. A formula in A1 that refers to A1 would create a circular reference, and you would lose a clear way to compare the result with the source.
- Remove every regular space with SUBSTITUTE. With the original text in A1 and the formula going in B1, enter
=SUBSTITUTE(A1," ",""). Press Enter. SUBSTITUTE looks for the ordinary space character between the first pair of quotation marks and replaces each occurrence with nothing, represented by the empty pair of quotation marks. For example, if A1 contains Blue sky, B1 returns Bluesky. The formula does not change A1. - Check that the result matches your intention. Compare B1 with A1. Look for missing word boundaries, punctuation, leading zeros, or other details that matter. If A1 contains AB 12 34, removing all spaces returns AB1234. If you meant to keep a gap between AB and 12, use TRIM instead of SUBSTITUTE. Do not proceed to overwrite the original until you are satisfied with the output.
- Replace the original only if you need a fixed value in that cell. Select B1 and copy it with Ctrl+C on Windows. Click A1, then choose Home > Paste > Values. This pastes the cleaned result without leaving a formula that depends on B1. In Excel for Mac, use the Home tab’s Paste Values command or the equivalent Paste Special option. Excel for the web also provides a Paste Values option. Keep B1 until you have checked A1; after that, you can delete the helper cell.
- Use TRIM when you want to preserve word spacing. With the source in A1 and the result in B1, enter
=TRIM(A1). If A1 contains three spaces before a word, two between words, and several after the final word, the result removes spaces at the beginning and end and reduces each run of internal ordinary spaces to one. For example, A1 containing Blue sky returns Blue sky. TRIM does not remove all spaces between words. - Use a limited replacement if only the first space should go. With the text in A1 and the result in B1, enter
=SUBSTITUTE(A1," ","",1). The final argument tells Excel to replace only the first matching space, counting from the left. If A1 contains Red blue green, the result is Redblue green. Leave off the final argument to remove every matching space instead. - Finish by checking the cell type and downstream use. SUBSTITUTE and TRIM return text. If the cleaned text looks like a number, Excel may still treat it as text, which can affect calculations or sorting. Confirm what the data represents before converting it to a number. Once you paste values over the source, test any formulas or lookups that use that cell.
The formula approach is a safe way to work on just one cell because it does not require a worksheet-wide Find and Replace. If you use Ctrl+H on Windows, Excel’s Replace command can act on a larger range or the sheet, depending on the selection and settings. Avoid choosing Replace All unless you have confirmed the search scope and the exact character being replaced.
Common Mistakes
- Using SUBSTITUTE when you only wanted tidy spacing. SUBSTITUTE removes every matching space, including spaces between words. For names and sentences where word boundaries should remain, use TRIM.
- Expecting TRIM to remove all internal spaces. TRIM keeps one ordinary space between words. It is a spacing-cleanup function, not an all-spaces-removal function.
- Typing the formula into the cell it refers to. If the formula is entered in A1 and also refers to A1, Excel may report a circular reference. Put the formula in another cell, check it, and paste the result back as values if needed.
- Copying the formula instead of its result. A regular paste may place a formula in the original cell that still refers to the helper cell. Use Paste Values when you want the cleaned text itself, independent of the helper formula.
- Confusing a visible gap with an ordinary space. Data copied from websites, PDFs, or other systems may contain a nonbreaking space or another invisible character. SUBSTITUTE with a normal space will not find a different character.
- Removing spaces from identifiers without checking the rules. An account number, postal code, or product code may require specific formatting. Check the expected format before cleaning it, especially if another system uses the spaces as separators.
Tips
- Keep the source and result side by side first. A helper cell makes the change easy to inspect and gives you a simple fallback if the output is wrong. This is especially useful when the cell contains a long address, description, or code.
- Use a clear helper heading. For a one-off cleanup, a nearby blank cell is enough. If you are cleaning a list, label the result column Cleaned text so that you do not confuse the formula output with the original data.
- Fill down only when you want to clean more than one cell. For a list in A2:A20, place the formula beside the first entry and use the fill handle to copy it down. Check the first few results before copying it through the full list. The relative reference will update for each row.
- Make a backup before replacing important data. Copy the source column to another worksheet or save a workbook copy. A normal formula change can be undone, but once you have made other edits or closed the file, a backup is more dependable.
- Use Find and Replace cautiously. It can be convenient for a selected range, but verify the range and Find what field before replacing. A single active cell does not always mean Replace All is limited to that cell, so the helper-formula method is safer when only one cell must change.
- Remember that spaces are not the only invisible characters. If a value still appears misaligned after cleaning, inspect for tabs, line breaks, or nonbreaking spaces. A formula that removes ordinary spaces will not necessarily remove those other characters.
Troubleshooting
- The formula appears as text instead of calculating. The cell may be formatted as Text, or the formula may have been entered with an apostrophe before the equals sign. Change the formula cell’s format to General, edit the cell, and press Enter again. Also confirm that the entry begins with an equals sign.
- Excel shows a formula error after you enter it. Check that the parentheses and quotation marks are balanced and that the formula references the correct source cell. If your regional Excel settings require semicolons between arguments, replace the commas with semicolons; the formula names and empty-string argument remain the same.
- Some spaces remain after SUBSTITUTE. The remaining gaps may be nonbreaking spaces. With the source in A1 and the result in B1, try
=SUBSTITUTE(SUBSTITUTE(A1,CHAR(160),"")," ",""). This removes character 160 and ordinary spaces. If the remaining character is a tab or line break instead, this formula will not remove it; identify that character before choosing a cleanup method. - TRIM leaves an unwanted gap between words. That is expected: TRIM reduces repeated ordinary spaces to one. If you want no ordinary spaces anywhere, use SUBSTITUTE. If the gap is a nonbreaking space, first replace that character as well; ordinary TRIM may not recognize it.
- The cleaned value is not treated as a number. SUBSTITUTE and TRIM produce text. If the result should be numeric, verify that it contains only valid number characters and then convert it using Excel’s available number-conversion options. Do not convert codes with meaningful leading zeros into numbers.
- Paste Values is not obvious. Open the Home tab’s Paste menu and choose the Values option, or right-click the destination and look for the values-only paste icon. If you paste normally and the result changes when the helper cell changes, undo and paste values instead.
Frequently Asked Questions
How do I remove all spaces from just one Excel cell?
Put a SUBSTITUTE formula in a helper cell that refers to the target cell. For example, if the source is A1, =SUBSTITUTE(A1," ","") removes all ordinary spaces from its result. Copy the result and paste values over A1 if you want to replace the original.
How do I remove only spaces at the beginning and end?
Use TRIM in a helper cell. It removes leading and trailing ordinary spaces and reduces repeated internal ordinary spaces to one. It does not preserve multiple spaces between words exactly, so inspect the result before replacing the original.
Can I remove one space without removing the others?
Yes. Use SUBSTITUTE with its optional occurrence number. With the text in A1, =SUBSTITUTE(A1," ","",1) removes the first ordinary space only. Change the final 1 to 2 to remove the second one instead, if that occurrence exists.
Why does SUBSTITUTE not remove every visible gap?
The cell may contain a different whitespace character, such as a nonbreaking space copied from a web page. The normal-space formula only matches ordinary spaces. For character 160, use the nested SUBSTITUTE example in Troubleshooting, then check for other characters if gaps remain.
Can I use Find and Replace for one cell?
You can open Replace with Ctrl+H on Windows, but check the search scope carefully before using Replace All. The command may affect a larger area than intended. A helper formula is the more controlled option when you need to change one cell and preserve everything else.
Will removing spaces change a number?
It can change the value’s meaning. For example, removing a gap from text such as 12 34 produces 1234, and formula results are text even when they look numeric. Check whether the spaces are separators and whether leading zeros must be kept before converting or using the result in calculations.
Related
- Excel Day Based on Date: Find the Weekday
- Excel Day Care in Clementi: Location and Enrolment Guide
- Excel Day Care in Jurong East: Location, Fees and Checks
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Shortcut to Pull Down a Formula: Fill Down FastIn Excel for Microsoft 365 on Windows, select the formula cell and the cells below where you want…
- VLOOKUP in Excel: Return a Value from Another CellTo make VLOOKUP return a value from another cell, look up a key in the leftmost column of…
- Excel Power Query vs Formulas: Which Should You Use?Use Excel formulas when you want calculations to update as you edit worksheet cells; use Power Query when…
- How to Calculate Age in Excel for a Future Date with DATEDIFIf the date of birth is in A2 and the future date you want to measure age on…
- Round Excel Numbers Without a Formula: Display or ChangeYes. In Excel for Microsoft 365 on Windows, use a number format to display fewer decimal places without…
- Extract Text in an Excel Cell: Formulas and Steps That WorkTo extract part of a cell’s text, use a formula such as TEXTBEFORE for text before a separator,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.