Eliminate all spaces in a text string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a function that will eliminate ALL spaces in a text string? TRIM
will eliminate all unnecessary spaces, but I have been asked if you can
eliminate all of them.

Thanks for any help.
Regards
Aehan
 
Thank you very much JoAnn, I should have thought of that - instead I've been
searching for a complicated formula!! Doh!

JoAnn Paules said:
Find and replace the spaces with nothing.

--
JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375


aehan said:
Is there a function that will eliminate ALL spaces in a text string? TRIM
will eliminate all unnecessary spaces, but I have been asked if you can
eliminate all of them.

Thanks for any help.
Regards
Aehan
 
Use the Replace function:

Sub TestMacro()

Dim x As String
Dim y As String

x = " text with spaces "

y = Replace(x, " ", "")

Debug.Print y ' Prints: textwithspaces

End Sub

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
I'm usually the one who's trying to do something the hard way. ;-)

--
JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375


aehan said:
Thank you very much JoAnn, I should have thought of that - instead I've
been
searching for a complicated formula!! Doh!

JoAnn Paules said:
Find and replace the spaces with nothing.

--
JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375


aehan said:
Is there a function that will eliminate ALL spaces in a text string?
TRIM
will eliminate all unnecessary spaces, but I have been asked if you can
eliminate all of them.

Thanks for any help.
Regards
Aehan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top