Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove spaces from a string variable


Does anyone know if there is a function to remove or replace space
within a string variable in VBA. I want something similar to the TRI
function that also removes spaces from middle of the string as well a
the ends.

Thank

--
blatha
-----------------------------------------------------------------------
blatham's Profile: http://www.excelforum.com/member.php...fo&userid=1944
View this thread: http://www.excelforum.com/showthread.php?threadid=39850

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove spaces from a string variable


Thanks but when I try this it doesn't recognise the Sub or Function.
Does it need a reference to a particular library to be set for it t
work

--
blatha
-----------------------------------------------------------------------
blatham's Profile: http://www.excelforum.com/member.php...fo&userid=1944
View this thread: http://www.excelforum.com/showthread.php?threadid=39850

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove spaces from a string variable


Hmmm... wouldn't really know why it can't recognize... Replace i
supposed to be a "standard" method. It's a member of the String
Module. Try using dot-notation:

Strings.Replace("dunno why...", "dunno", "do know")

sorry, don't have much idea... :(

blatham Wrote:
Thanks but when I try this it doesn't recognise the Sub or Function.
Does it need a reference to a particular library to be set for it t
work


--
T-®e
-----------------------------------------------------------------------
T-®ex's Profile: http://www.excelforum.com/member.php...fo&userid=2657
View this thread: http://www.excelforum.com/showthread.php?threadid=39850

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove spaces from a string variable


Nah, perhaps it was introduced in a later version. Suppose 97 is a bit
old now! Thanks anyway.


--
blatham
------------------------------------------------------------------------
blatham's Profile: http://www.excelforum.com/member.php...o&userid=19441
View this thread: http://www.excelforum.com/showthread...hreadid=398507

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Remove spaces from a string variable

Hi blatham

Replace and some other string functions are not available in XL97

Use Substitute in XL97, and the slightly faster Replace for later versions.
The conditional #If VBA6 will prevent a compile error in XL97's VBA5.

Sub test()

#If VBA6 Then
myStr = Replace("dunno why...", "dunno", "do know")
#Else ' it's XL97
myStr = Application.Substitute("dunno why...", "dunno", "do know")
#End If

End Sub

Regards,
Peter T

"blatham" wrote in
message ...

Nah, perhaps it was introduced in a later version. Suppose 97 is a bit
old now! Thanks anyway.


--
blatham
------------------------------------------------------------------------
blatham's Profile:

http://www.excelforum.com/member.php...o&userid=19441
View this thread: http://www.excelforum.com/showthread...hreadid=398507



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
How do I remove all spaces in a text string dn Excel Discussion (Misc queries) 3 April 2nd 23 07:20 PM
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
Find String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Remove spaces from a string variable T-®ex[_4_] Excel Programming 0 August 24th 05 09:25 AM
how do I remove empty spaces trailing a text string? Need_Help Excel Worksheet Functions 2 June 7th 05 12:13 AM


All times are GMT +1. The time now is 05:49 PM.

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

About Us

"It's about Microsoft Excel"