View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
T-容x[_4_] T-容x[_4_] is offline
external usenet poster
 
Posts: 1
Default Remove spaces from a string variable


Use the Replace method of Strings:

* To remove all spaces:
Replace(YourStringWithSpaces, " ", "")

* To replace spaces with underscores:
Replace(YourStringWithSpaces, " ", "_")

Hope this helps...

blatham Wrote:
Does anyone know if there is a function to remove or replace spaces
within a string variable in VBA. I want something similar to the TRIM
function that also removes spaces from middle of the string as well as
the ends.

Thanks



--
T-容x
------------------------------------------------------------------------
T-容x's Profile: http://www.excelforum.com/member.php...o&userid=26572
View this thread: http://www.excelforum.com/showthread...hreadid=398507