Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Space in Excel: How to Add, Remove & Fix

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To put a space in Excel, type it directly into a cell or use a formula like =" " to create a single space. To add spaces between text from different cells, use the & operator with " " (e.g., =A1&" "&B1) or the TEXTJOIN function. To remove extra spaces, use TRIM for normal spaces or SUBSTITUTE for non-breaking spaces (CHAR(160)). This guide covers adding, removing, and troubleshooting spaces in Excel across Windows, Mac, and Excel for the web.

What You'll Need

  • Excel 2016 or later (Windows, Mac, or Excel for the web). Most steps work in older versions too, but menu labels may differ.
  • Basic familiarity with formulas and the formula bar.
  • Your data open in a worksheet.

Step-by-Step

  1. Add a space inside a cell: Click the cell, type the text, and press the spacebar where you want the gap. Press Enter. To force a line break within the cell, press Alt+Enter (Windows) or Control+Option+Return (Mac).
  2. Insert a single space with a formula: In an empty cell, type =" " and press Enter. The cell now contains one space character. This is useful when you need a space as a building block for other formulas.
  3. Join text with spaces using &: If A1 contains "Hello" and B1 contains "World", type =A1&" "&B1 in another cell. The result is "Hello World". Add more &" "& segments for additional words.
  4. Use TEXTJOIN for many cells: In Excel 2019 or Microsoft 365, type =TEXTJOIN(" ",TRUE,A1:C1). This joins values from A1 to C1 with a space between each, ignoring empty cells. The first argument is the delimiter (a space), the second TRUE ignores blanks, and the third is the range.
  5. Use CONCAT or CONCATENATE (older Excel): Type =CONCATENATE(A1," ",B1) or =CONCAT(A1," ",B1). CONCAT is available in Excel 2019 and later; CONCATENATE works in all versions but is being phased out.
  6. Remove leading, trailing, and extra internal spaces: Use =TRIM(A1). TRIM removes leading and trailing spaces and reduces multiple internal spaces to one. It does not remove non-breaking spaces (CHAR(160)).
  7. Remove non-breaking spaces: If TRIM does not work, the spaces may be non-breaking (common when copying from web pages). Use =SUBSTITUTE(A1,CHAR(160)," ") first, then wrap with TRIM: =TRIM(SUBSTITUTE(A1,CHAR(160)," ")). This replaces non-breaking spaces with normal spaces, then trims.
  8. Remove all spaces: To delete every space character, use =SUBSTITUTE(A1," ",""). This removes all normal spaces, including those between words. Combine with the CHAR(160) substitution if needed.
  9. Find and replace spaces: Select your range, press Ctrl+H (Windows) or Command+H (Mac). In "Find what", type a space; leave "Replace with" blank to delete spaces, or type a different character. Click "Replace All". This works for normal spaces only; non-breaking spaces need the formula method or a wildcard search.
  10. Add a space before a capital letter (e.g., for names): Use a formula like =TRIM(SUBSTITUTE(A1," "," ")) is not enough. Instead, use =TRIM(REGEXREPLACE(A1,"([a-z])([A-Z])","$1 $2")) in Excel 365 (REGEXREPLACE is available in Microsoft 365). For older versions, use a helper column with a formula like =LEFT(A1,1)&IF(MID(A1,2,1)=UPPER(MID(A1,2,1))," "&MID(A1,2,1),MID(A1,2,1))&... but this is complex; consider using Flash Fill (Ctrl+E) after typing an example.
  11. Use Flash Fill to add spaces: In a column next to your data, type the desired result for the first row (e.g., "John Smith" from "JohnSmith"). Press Enter, then press Ctrl+E (Windows) or Command+E (Mac). Excel fills the rest based on your pattern. Verify the results and correct any mistakes.
  12. Check for spaces with LEN: Use =LEN(A1) to count characters including spaces. Compare with =LEN(TRIM(A1)) to see if extra spaces exist. If the numbers differ, TRIM will remove them.
  13. Replace spaces with line breaks: Use =SUBSTITUTE(A1," ",CHAR(10)) and enable Wrap Text (Home tab > Wrap Text). This turns each space into a line break within the cell.

Common Mistakes

  • Using TRIM on non-breaking spaces: TRIM only handles normal spaces (CHAR(32)). Non-breaking spaces (CHAR(160)) remain. Use SUBSTITUTE with CHAR(160) first.
  • Forgetting that & needs quotes around the space: Writing =A1& &B1 without quotes causes a formula error. Always use " " for a space literal.
  • Assuming TRIM removes all spaces: TRIM leaves single spaces between words. To remove all spaces, use SUBSTITUTE.
  • Overlooking trailing spaces in lookups: VLOOKUP and XLOOKUP may fail if one value has a trailing space. Use TRIM on both the lookup value and the table array, or clean the data first.
  • Typing spaces in number cells: Excel may treat a number with a space as text. Use cell formatting (e.g., custom format) instead of typing spaces for alignment.

Tips

  • Use =TRIM(CLEAN(A1)) to remove both extra spaces and non-printing characters. CLEAN removes characters like line breaks and tabs.
  • To add a space at the start or end of a cell, use =" "&A1 or =A1&" ". Be aware that trailing spaces can cause lookup issues.
  • When concatenating many cells, TEXTJOIN is more efficient and easier to read than multiple & operators.
  • Use Flash Fill (Ctrl+E) for quick pattern-based text transformations, but always review the results.
  • To find cells with leading or trailing spaces, use a formula like =A1<>TRIM(A1) and filter for TRUE.

Troubleshooting

  • TRIM does not remove spaces: The spaces are likely non-breaking. Use =TRIM(SUBSTITUTE(A1,CHAR(160)," ")). If that fails, check for other Unicode spaces (e.g., CHAR(8195)) and substitute them similarly.
  • Formula returns #VALUE!: Check that you have quotes around the space and that cell references are correct. For TEXTJOIN, ensure the range is valid and the delimiter is in quotes.
  • Spaces disappear when pasting: If pasting from another program, use Paste Special > Values to avoid formatting issues, or paste into Notepad first to strip formatting.
  • Cannot see spaces: Enable "Show Formulas" (Ctrl+`) or use LEN to count characters. You can also use Find & Replace with a space in "Find what" to highlight occurrences.
  • Flash Fill does not work: Ensure the example is in the same column and that Excel recognizes the pattern. Try typing more examples or use a formula instead.

Frequently Asked Questions

How do I add a space between first and last names in Excel?

If first names are in column A and last names in column B, use =A1&" "&B1 in a new column. Copy down, then convert to values if needed.

Why does TRIM not remove all spaces?

TRIM only removes normal spaces (CHAR(32)). Non-breaking spaces (CHAR(160)) from web pages remain. Use SUBSTITUTE with CHAR(160) before TRIM.

How can I remove all spaces from a cell?

Use =SUBSTITUTE(A1," ",""). For non-breaking spaces, nest: =SUBSTITUTE(SUBSTITUTE(A1," ",""),CHAR(160),"").

Can I add a space after every comma in a list?

Yes, use =SUBSTITUTE(A1,",",", "). This replaces each comma with a comma followed by a space.

How do I insert a line break instead of a space?

Use =SUBSTITUTE(A1," ",CHAR(10)) and turn on Wrap Text. On Windows, you can also press Alt+Enter while editing a cell.

What is the difference between CHAR(32) and CHAR(160)?

CHAR(32) is a normal space; CHAR(160) is a non-breaking space. They look similar but behave differently in formulas and sorting.