How am i able to add a space after a certain Pattern
Example: DS9 DS10DS11 DS12
Result: DS9 DS10 DS11 DS12
Example 2: C1 C2 C3C4 C5
Result: C1 C2 C3 C4 C5
Before I get the example, I use a CleanTrim function to remove the double line
Function CleanTrim(ByVal S As String, Optional ConvertNonBreakingSpace As Boolean = True) As String
Dim X As Long, CodesToClean As Variant
CodesToClean = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, _
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127, 129, 141, 143, 144, 157)
If ConvertNonBreakingSpace Then S = Replace(S, Chr(160), " ")
For X = LBound(CodesToClean) To UBound(CodesToClean)
If InStr(S, Chr(CodesToClean(X))) Then S = Replace(S, Chr(CodesToClean(X)), "")
Next
CleanTrim = WorksheetFunction.Trim(S)
End Function
I want to be able to split the String using a Space Delimiter but there are some wording there does not have any space.
I have consider using the Addspace function which add a space in front of a capital letter. but in the event where there is 2 capital letter. There will be 2 spaces
Function Add_Spaces(ByVal sText As String) As String
Dim CharNum As Long
Dim FixedText As String
Dim CharCode As Long
FixedText = Left(sText, 1)
For CharNum = 2 To Len(sText)
CharCode = Asc(Mid(sText, CharNum, 1))
If CharCode >= 65 And CharCode <= 90 Then
FixedText = FixedText & " " & Mid(sText, CharNum, 1)
Else
FixedText = FixedText & Mid(sText, CharNum, 1)
End If
Next CharNum
Add_Spaces = FixedText
End Function
