ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove spaces from a string variable (https://www.excelbanter.com/excel-programming/338142-re-remove-spaces-string-variable.html)

T-Žex[_4_]

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-Žex
------------------------------------------------------------------------
T-Žex's Profile: http://www.excelforum.com/member.php...o&userid=26572
View this thread: http://www.excelforum.com/showthread...hreadid=398507



All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com