Removal of spaces

N

Neil

I have some code that gets the value from a couple of
combo boxes and strings it together using "&" and then
places it in a text box. I want to be able to examine
this text, look for any spaces and remove them before
placing it in the text box. How can i do this?
 
C

Colo

Neil,

You can use "replace".
Please change "a b c" to the variable that you are using.


Code:
 
R

Rob van Gelder

Neil,

Sub testit()
Dim strMyValue As String

strMyValue = "T h e A b y s s"
ComboBox1.AddItem Replace(strMyValue, " ", "")
End Sub

Rob
 
T

Tom Ogilvy

Replace was added in Excel 2000, so if you will use the code in an earlier
version

sStr = Application.Substitute(sStr," ","")
 
Top