Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Removal of spaces

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Removal of spaces

Neil,

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


Code:
--------------------

replace("a b c"," ","")

--------------------



---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Removal of spaces

Use Trim, Rtrim or Ltrim to remove leading and trailing spaces from a text
string
eg
mystring = " this is some text "

remove leading spaces with
mynewstring = Ltrim(mystring)

remove trailing spaces with
mynewstring = Rtrim(mystring)

remove both leading and trailing
mynewstring = Trim(mystring)

Do this before you concatenate your strings with &

mynewstring = Trim(string1) & Trim(string2) & Trim(string3)

Cheers
Nigel



"Neil" wrote in message
...
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?





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Removal of spaces

Neil,

Sub testit()
Dim strMyValue As String

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

Rob


"Neil" wrote in message
...
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?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Removal of spaces

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

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

--
Regards,
Tom Ogilvy

"Neil" wrote in message
...
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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removal of Zero vmohan1978 Excel Worksheet Functions 4 January 24th 10 07:29 AM
Password Removal DaS Excel Discussion (Misc queries) 3 February 6th 08 07:04 PM
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
spaces not recognized as spaces windsurferLA Excel Worksheet Functions 9 July 27th 06 11:49 AM
Hyperlink Removal lsmft Excel Discussion (Misc queries) 3 February 23rd 06 10:23 AM


All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"