cansevin
asked on
Pull named out of Cell
We have a column of data all in Column A. In column B I would like it to pull out the First and Last Name. This is always right after the time - which ends in either "am" or "pm". Is there a way to pull out the 2 words after the "am" or "pm"? This would always be the name we need.
Is it always just the time and First Name Last Name eg:
4:15 pm Fred Bloggs
I suspect you can do it with the text to columns wizard, an upload with some sample data would confirm.
4:15 pm Fred Bloggs
I suspect you can do it with the text to columns wizard, an upload with some sample data would confirm.
I admit that my solution is tailored very tight to the example you've given, but nevertheless: Here is it: ...
Put that Function code into a macro module within your Excel workbook. Then you could use it like this:
(your example texts in column A, function calls in column F)
Hope that helps ...
Function GetName(s As String) As String
Dim token As Variant
Dim s2 As String
Dim i As Integer
i = 0
i = WorksheetFunction.Max(InStr(1, s, " am ") + 4, InStr(1, s, " pm ") + 4)
s2 = Mid(s, i)
For Each token In Split(s2, " ")
If Left(token, 1) = "$" Then Exit For
GetName = GetName + IIf(GetName = "", "", " ") + token
Next
End Function
Put that Function code into a macro module within your Excel workbook. Then you could use it like this:
(your example texts in column A, function calls in column F)
Hope that helps ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
=MID(A1,IF(ISNUMBER(SEARCH