View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Extract Name from Text

Assuming your names are **always** made up of two parts (a first and last
name) and that they are **always** followed by either a dot-extension (.xlsm
in your example) or a space (separating it from the non name parts), then
this macro should do what you want...

Sub GetNames()
Dim Cell As Range, Text As String, Parts() As String
For Each Cell In Range("A1:A4")
Text = Replace(Split(Cell, "\")(UBound(Split(Cell, "\"))), ".", " ")
Parts = Split(Text, " ", 3)
Parts(2) = ""
Cell.Offset(0, 1).Value = Trim(Join(Parts))
Next
End Sub

--
Rick (MVP - Excel)


"K" wrote in message
...
I got below data in Range("A1:A4")

C:\Documents\Deal\Tony Jayes.xlsm
C:\Documents\Records\John Smith (Survey Form).xlsm
C:\Documents\Project\Michael Taylor - MCC.xlsm
C:\Documents\Records\Simon Craig (FTT).xlsm

I need some formula or macro to get result in Range("B1:B4") like
below

Tony Jayes
John Smith
Michael Taylor
Simon Craig

Basically I want names to be extracted from column A Text. Please
can anyone can help