hi,
first if you use SUBSTITUTE the cell contains a text entry and you say value.
second to remove trailing and leading spaces use:
=TRIM(A1)
It also removes extra spaces between characters (extra being more than 1)
In both case your results are text, to change them to values the easiest way
is to
=--TRIM(A1)
or
=--SUBSTITUTE(A1," ","")
You can combine both of these
=--TRIM(SUBSTITUTE(A1," ",""))