View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
moon[_5_] moon[_5_] is offline
external usenet poster
 
Posts: 40
Default Inserting and deleting spaces with a macro


=LEFT(A1,FIND(",",A1,1)-1) & ", " & MID(A1,FIND(",",A1,1)+1,(FIND("
",A1,1)-FIND(",",A1,1)))

or

Public Function CleanUpString(nameInCell As String) As String

CleanUpString = Left(nameInCell, InStr(1, nameInCell, ",",
vbTextCompare) - 1) & ", " & Mid(nameInCell, InStr(1, nameInCell, ",",
vbTextCompare) + 1, (InStr(1, nameInCell, " ", vbTextCompare) - InStr(1,
nameInCell, ",", vbTextCompare)))

End Function



"crowdx42" schreef
in bericht ...

Ok,
so I have names in a column which I want to both insert a space after
a "," and then delete everything after the second word space. i.e
James,Patrick Coogan needs to be
James, Patrick
Can this be done?
Thanks in advance
You guys have been very patient and I very much appreciate all the
help.
Patrick:)


--
crowdx42
------------------------------------------------------------------------
crowdx42's Profile:
http://www.excelforum.com/member.php...o&userid=37749
View this thread: http://www.excelforum.com/showthread...hreadid=574054