Removing Middle Initial or Middle Name

Mschweider

New Member
Joined
Mar 2, 2015
Messages
12
I have a document where the name format is Last, First Middle Name/Initial. (Sometimes there is a period at the end of the middle initial, sometimes there is not, see below).

I was wondering if it was possible to remove the Middle name/initial using macros. I have found some help but there always seems to be something wrong in at least one case. The list of names is 1533 so I would like it to work without any input from me.

Some example name formats:
Smith, John
Smith, John L
Smith, John L.
Smith Dean, John (Smith Dean is two last names)
Smith Dean, John L
Smith Dean, John L.

I would like it to work with all of those difference since that is how the file comes to me, if possible.

This is the current formula I have found but it doesn't work with two last names:

=IF(LEN(A3)-LEN(SUBSTITUTE(A3," ",""))=1,A3,SUBSTITUTE(LEFT(A3,FIND("^^",SUBSTITUTE(A3," ","^^",2))-1),",","",2))

Thanks for any help!
 
If the OP's list had this author's name, or names similarly constructed like it, then your formula would return an incorrect result...

Rowling, J. K.

Also, as written, your formula cannot be copied down past the end of existing data in anticipation for the future addition of more names as it returns a #VALUE! error if the cell is empty.

The OP did not ask handling „Rowling J. K.” type structures. But if he did I would suggest:

=IFERROR(REPLACE(A1,SEARCH(" ?#",SUBSTITUTE(A1,".","")&"#"),3,""),””&A1)

I think it is not highly unusual to let the formula display #VALUE error if it bumps into an empty cell (for example, almost all formulae in this thread give „#VALUE” for empty cells). However, it can be overcome by inserting the red part.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The OP did not ask handling „Rowling J. K.” type structures.
True, but I find it quite common that OPs fail to tell us everything we need to know about their data. I would also note that I started my comment with "If"... I was not criticizing your formula per se, just noting a possible problem in case it meant something to the OP.


I think it is not highly unusual to let the formula display #VALUE error if it bumps into an empty cell (for example, almost all formulae in this thread give „#VALUE” for empty cells). However, it can be overcome by inserting the red part.
:oops: I am quite embarrassed by my comment on this one. My first posted formula does not display the #VALUE! error for missing data, then I forgot to check for it in the formulas I posted afterwards. I usually like to hid the error if done easily, so with that in mind, here is my last posted formula modified to hide the error, again, in case that might matter to the OP...

=IF(MID(A1,LEN(" "&A1)-3-(RIGHT(A1)="."),1)=" ",TRIM(LEFT(A1,LEN(A1)-2)),TRIM(" "&A1))
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top