View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Inserting and deleting spaces with a macro

You could select your range
edit|replace
what: (spacebar)* (two characters total)
with: (leave blank)
replace all

edit|Replace
what: ,
with: ,(spacebar)
replace all

If you needed code:
Option Explicit
Sub testme()
With Selection
.Replace What:=" *", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False
.Replace What:=",", Replacement:=", ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False
End With
End Sub


crowdx42 wrote:

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


--

Dave Peterson