erase all space characters into string

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

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
 
Date: Sun, 16 Jan 2005 11:48:01 +0100
To: Maileen <[email protected]>
Bcc: Jan Karel Pieterse <[email protected]>
Subject: Re: erase all space characters into string
From: Jan Karel Pieterse <[email protected]>

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
 
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
 
Back
Top