ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   erase all space characters into string (https://www.excelbanter.com/excel-programming/320909-erase-all-space-characters-into-string.html)

Maileen[_2_]

erase all space characters into string
 
Hi,

I would like to know how can i do to erase all space characters into a
string ?

i tried TRIM but it's only for left and right sides, not for inside the
string itself..

I would like to get from " this is a string ", this string "thisisastring".

should i proceed characters per character ?

thx,
Maileen

Jan Karel Pieterse

erase all space characters into string
 
Date: Sun, 16 Jan 2005 11:48:01 +0100
To: Maileen
Bcc: Jan Karel Pieterse
Subject: erase all space characters into string
From: Jan Karel Pieterse

Hi Maileen,

I would like to get from " this is a string ", this string

"thisisastring".

Dim sString as String
sString=" this is a string "
sString=Replace(sString," ","")
Msgbox sString

Works for Excel 2000 and up.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Ron de Bruin

erase all space characters into string
 
Or use EditReplace in the Menu Bar

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Jan Karel Pieterse" wrote in message ...
Date: Sun, 16 Jan 2005 11:48:01 +0100
To: Maileen
Bcc: Jan Karel Pieterse
Subject: erase all space characters into string
From: Jan Karel Pieterse

Hi Maileen,

I would like to get from " this is a string ", this string

"thisisastring".

Dim sString as String
sString=" this is a string "
sString=Replace(sString," ","")
Msgbox sString

Works for Excel 2000 and up.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com




Jan Karel Pieterse

erase all space characters into string
 
Hi Ron,

Or use EditReplace in the Menu Bar


I assumed this was a VBA question.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Rob van Gelder[_4_]

erase all space characters into string
 
I've also seen this used for Excel 97

Sub test()
Dim str As String

str = " this is a string "

str = WorksheetFunction.Substitute(str, " ", "")

MsgBox str
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Jan Karel Pieterse" wrote in message
...
Date: Sun, 16 Jan 2005 11:48:01 +0100
To: Maileen
Bcc: Jan Karel Pieterse
Subject: erase all space characters into string
From: Jan Karel Pieterse

Hi Maileen,

I would like to get from " this is a string ", this string

"thisisastring".

Dim sString as String
sString=" this is a string "
sString=Replace(sString," ","")
Msgbox sString

Works for Excel 2000 and up.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com





All times are GMT +1. The time now is 01:05 AM.

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