Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Ella Campbell   on Oct 05 In MS Office Category.

  
Question Answered By: Rudy Turner   on Oct 05

This is very fast....

Function fncStripJoin(spS As String) As String

Dim slS() As String

slS = Split(spS," ")
fncStripJoin = Join(slS, "")
' ***********************************************************************
End Function

I also use a "generic" procedure which will strip any single or set of
characters including control characters.

Function fncStripChrs(strpString As String)
' Strip some characters.

Dim intlM As Integer
Dim strlS As String

strlS = ""
For intlM = 1 To Len(strpString)
Select Case Asc(Mid(strpString, intlM, 1))
Case 13, 7, 10, 9, 150, 147 ' List of Ascii codes for stripping.
Case Else
strlS = strlS & Mid(strpString, intlM, 1)
End Select
Next
fncStripChrs = strlS
' ***********************************************************************
End Function

... And finally this one.

Function fncAllTrim(spS As String) _
As String
' Trim all spaces  from a string.

Dim slS As String
Dim ilChr As Integer
Dim slChr As String * 1

slS = ""
For ilChr = 1 To Len(spS)
slChr = Mid(spS, ilChr, 1)
If slChr <> " " Then
slS = slS & slChr
End If
Next ilChr
fncAllTrim = slS
' ***********************************************************************
End Function

I did have a function  where you passed a list of chrs to zap but I couldn't
find it... Sorry.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Remove the spaces between characters in VBA Or get search suggestion and latest updates.


Tagged: