#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
NWO NWO is offline
external usenet poster
 
Posts: 60
Default Easy one...

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A, and
Bennett Joan (last name first name middle initial - commas OK) I tried the
Pearson example, but it had commas and the last name was first, so it didn't
work for my problem.

Thank you.

NWO Mark
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Easy one...

Try this UDF:

Function swapit(r As Range) As String
s = Split(r.Value, " ")
If UBound(s) = 2 Then
swapit = s(2) & " " & s(0) & " " & s(1)
Else
swapit = s(1) & " " & s(0)
End If
End Function
--
Gary''s Student - gsnu200742


"NWO" wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A, and
Bennett Joan (last name first name middle initial - commas OK) I tried the
Pearson example, but it had commas and the last name was first, so it didn't
work for my problem.

Thank you.

NWO Mark

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 136
Default Easy one...

If all parts of a name are in seperate fields, like:
A B C
John A Doe
Joan Bennett

Than enter this in column D:
=TRIM(CONCATENATE(C1,", ",A1,," ",B1))

"NWO" wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A, and
Bennett Joan (last name first name middle initial - commas OK) I tried the
Pearson example, but it had commas and the last name was first, so it didn't
work for my problem.

Thank you.

NWO Mark

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Easy one...

=IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=1,MID(A1,FIND(" ",A1)+1,99)&"
"&LEFT(A1,FIND(" ",A1)-1),MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,99)&"
"&LEFT(A1,FIND(" ",A1))&MID(A1,FIND(" ",A1)+1,1))

Note: The above formula will work with or without middle name as along as
middle name contain a single character.


"NWO" wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A, and
Bennett Joan (last name first name middle initial - commas OK) I tried the
Pearson example, but it had commas and the last name was first, so it didn't
work for my problem.

Thank you.

NWO Mark

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Easy one...

Fails on names like:

Martin St Louis (real name of a hockey player)
Oscar De La Hoya (real name of a boxer)

--
Biff
Microsoft Excel MVP


"Teethless mama" wrote in message
...
=IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=1,MID(A1,FIND(" ",A1)+1,99)&"
"&LEFT(A1,FIND(" ",A1)-1),MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,99)&"
"&LEFT(A1,FIND(" ",A1))&MID(A1,FIND(" ",A1)+1,1))

Note: The above formula will work with or without middle name as along as
middle name contain a single character.


"NWO" wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc
(no
commas, some have middle initial, some don't). How do I get Doe John A,
and
Bennett Joan (last name first name middle initial - commas OK) I tried
the
Pearson example, but it had commas and the last name was first, so it
didn't
work for my problem.

Thank you.

NWO Mark





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Easy one...

On Tue, 4 Sep 2007 16:36:00 -0700, NWO wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A, and
Bennett Joan (last name first name middle initial - commas OK) I tried the
Pearson example, but it had commas and the last name was first, so it didn't
work for my problem.

Thank you.

NWO Mark


The previously offered solutions seem to fail on those with multiple last
names, e.g. Oscar de la Hoya

My solution, which probably won't work all the time, assumes that
if a single letter follows the first name,
then that single letter is the middle,
otherwise it is part of the last name.

It requires a UDF.

To do this, <alt-F11 opens the VB Editor. Ensure your project is highlighted
in the project explorer window, then Insert/Module and paste the code below
into the window that opens.

To use this, enter a formula =LNFNMI(cell_ref) into some cell.

If you prefer to NOT have the comma after the Last Name, in the code below,
merely remove it from the CONST definition of sRes.

===========================================
Option Explicit
Function LNFNMI(str As String) As String
Dim re As Object
Const sPattern As String = "(^\w+)\s+(\w\b)?\s*(.*$)"
Const sRes As String = "$3, $1 $2"

Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = sPattern

LNFNMI = re.Replace(str, sRes)
End Function
====================================
--ron
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Easy one...

I beware of that, I quote on my reply: "Note: The above formula will work
with or without middle name as along as middle name contain a single
character."

"T. Valko" wrote:

Fails on names like:

Martin St Louis (real name of a hockey player)
Oscar De La Hoya (real name of a boxer)

--
Biff
Microsoft Excel MVP


"Teethless mama" wrote in message
...
=IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=1,MID(A1,FIND(" ",A1)+1,99)&"
"&LEFT(A1,FIND(" ",A1)-1),MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,99)&"
"&LEFT(A1,FIND(" ",A1))&MID(A1,FIND(" ",A1)+1,1))

Note: The above formula will work with or without middle name as along as
middle name contain a single character.


"NWO" wrote:

Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc
(no
commas, some have middle initial, some don't). How do I get Doe John A,
and
Bennett Joan (last name first name middle initial - commas OK) I tried
the
Pearson example, but it had commas and the last name was first, so it
didn't
work for my problem.

Thank you.

NWO Mark




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Easy one...

Why do you assume this is easy?


--
Regards,

Peo Sjoblom



"NWO" wrote in message
...
Ok, I have a list of names in the fomrat John A Doe, Joan Bennett, etc (no
commas, some have middle initial, some don't). How do I get Doe John A,
and
Bennett Joan (last name first name middle initial - commas OK) I tried
the
Pearson example, but it had commas and the last name was first, so it
didn't
work for my problem.

Thank you.

NWO Mark



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Should be easy Michell Major Excel Discussion (Misc queries) 8 November 27th 06 12:50 PM
This should be easy: Jaytee Excel Discussion (Misc queries) 3 October 1st 06 03:56 PM
I'm sure this is an easy one, but.... Omakbob Excel Worksheet Functions 6 October 31st 05 02:41 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
Probably Easy for you!! smorton Excel Discussion (Misc queries) 4 February 16th 05 09:10 PM


All times are GMT +1. The time now is 02:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"