When i copy and paste a table with numbers from an email to excel, there will be spaces before the numbers. Is there an easy formula to remove these spaces (i tried to add an image, but my post was removed)
Edit: thank you all for the support. The following formula solved it
=0+SUBSTITUTE(B2,CHAR(160),"")
Edit 2:
u/semicolonsemicolon & u/Joe3453 deserves credit for recognizing nbsp being the issue.
For curious lurkers: https://en.wikipedia.org/wiki/Non-breaking_space
Remove space(s) before a numerical value within a cell
Excel - deleting space from numbers - Stack Overflow
Remove spaces before and after the word in Cell
Remove Space Between Numbers in Excel
- Highlight the range that you want to modify
- CTRL + F
- Click Replace
- "Find what: " (put a blank space here so it searches for spaces)
- "Replace with: " (leave this blank)
- Click Replace all, and the selected range should search for blank spaces and replace them with nothing
There are two functions you can use for replacing a character in a string: Replace() and Substitute():
Replace()can be used when you know where you want to replace whatever.Substitute()can be used if you know exactly what you want to replace anywhere.
So, in this case:
=SUBSTITUTE(C2," ","")
If trim isn’t working for you, why not do a simple find and replace of the “space” character. That may well work for you.
I know this is a very basic function but even after searches and a YouTube video, I can’t seem to find how to do this and funny, I’ve done it before…
I need to remove the spaces in a row…I’ve tried following examples of the TRIM function but it just doesn’t seem to be working correctly…
Here’s what the numbers look like:

I have about 280 of these and only need the spaces removed from those numbers all in the same column.
Thanks…
TRIM will remove leading and trailing spaces, but not ones in the middle.
SUBSTITUTE does work, however, if we assume that all you want to do is remove all spaces:
=SUBSTITUTE(A1; " "; "")

If SUBSTITUTE fails to remove all the spaces, it may be because they are non-breaking -- see this answer.
Note that it's not necessary to use TRIM prior to using SUBSTITUTE if the space characters are all the same. It's also possible to chain SUBSTITUTE with itself -- refer to the linked answer for an example.
SUBSTITUTE can also be modified to target only specific instances.
I was able to remove the leading and trailing by using the following code. Where cell A1 contains the value that you are trimming:
=TRIM(SUBSTITUTE(A1,CHAR(160),CHAR(32)))
After you will have to copy and paste the value to remove the formula, unless someone else knows how to do that automatically.
