View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme Bernard Liengme is offline
external usenet poster
 
Posts: 4,393
Default Extract specific text

Somewhere in my workbook (it matter not where) I have a range called Mylist.
I contains the names
Blow, Joe
Liengme, Bernard
Smith, Anne
Taylor, George

but, of course, it could be longer.

In A1 and A2 I have your data
3-PKR11500 TGDL1 TAYLOR, GEORGE 15:00 - 23:00 x
3-SP12300 TGDS2 BLOW, JOE 23:00 - 7:00 x


In B1 and B2 I call a UDF with =getname(A1,mylist)

The UDF is:

Function getname(mycell, mylist)
mycount = mylist.Count
getname = "not found"
For j = 1 To mycount
testname = UCase(mylist(j).Value)
whatname = mycell.Value
MyPos = InStr(whatname, testname)
If MyPos < 0 Then
getname = mylist(j)
Exit For
End If
Next
End Function

The formulas return the correct names from MyList

Need help with VBA? See David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"NunRacer" wrote in message
...
I've tried searching for some solutions to my problem but havnt found
anything that really helps me.

I want to extract a persons name (the name is mixed up with other useless
info, and doesnt follow the same format) from a cell that matches the
names i
have in a Database.

so example would be
3-PKR11500 TGDL1 TAYLOR, GEORGE 15:00 - 23:00 x
3-SP12300 TGDS2 BLOW, JOE 23:00 - 7:00 x
So i need a formula to pull the name out by comparing it to the existing
names in the database.
The end result needs to be just their name.
Thank You.