View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Split with consecutive delimiters

The following removes multiple spaces from a cell:

Sub break_up()
''''''''''''''''''''''''''''''''''''''''''''
' converts multiple spaces to a single space
''''''''''''''''''''''''''''''''''''''''''''
Dim v As String
Dim v_out As String
v = Selection.Value
v_out = ""
c = 0
For i = 1 To Len(v)
vv = Mid(v, i, 1)
If vv = " " Then
c = c + 1
Else
Select Case c
Case 0
v_out = v_out & vv
Case 1
v_out = v_out & " " & vv
Case Is 1
v_out = v_out & " " & vv
End Select
c = 0
End If
Next
Selection.Value = v_out
End Sub

you can adapt the logic to remove multiple spaces from your string before
"splitting" it.
--
Gary''s Student - gsnu200721