View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1357_] Rick Rothstein \(MVP - VB\)[_1357_] is offline
external usenet poster
 
Posts: 1
Default String separated with commas

Sub dural()
s = "a, b, c, d, e"
s2 = Split(Replace(s, " ", ""), ",")
End Sub


You do not have to use the replace function to pare down the delimiter to a
single character like that... the delimiter can contain multiple
characters...

s2 = Split(s, ", ")

where the characters between the quote marks are a comma followed by a
space. Now, with that said, doing what you posted will protect against a
improperly formed string of text where the number of spaces following the
comma are not consistent throughout the text.

Rick