separating multiple Proper names (uppercase letters) from a list

Keebler

Board Regular
Joined
Dec 1, 2021
Messages
167
Office Version
  1. 2021
Platform
  1. Windows
I have a list of proper names that only has spaces between their first and last names. I need a formula that can separate these names into adjacent cells...
ex:
Jim BobJo JamesMike PettersonDirk Smith Jim Bob Jo James Mike Peterson Dirk Smith

Jim BobJo JamesMike PetersonDirk SmithJim BobJo JamesMike PetersonDirk Smith
does that make any sense?

thank you
Ken

to add injury to insult.. there are a few times that I have seen Proper names with McFlury or people with 2 last names Like JoEllen Smith-Peterson

thank you
 
Last edited by a moderator:
Thanks for the XL2BB sample.

With Eric's formula, you have the exact same formula in each cell. You need to put the first formula in, say BS1 and then drag that formula across using the Fill Handle at the bottom of the cell
1638620698160.png


With the vba function it is producing the second name because you now have the formula
=GetName($H1,COLUMNS($BY:BZ))
not
=GetName($H1,COLUMNS($BY:BY))
like you had before. Again you drag the Fill handle across.
With that particular example, the third name will be missing because it has two spaces between Brent and Lentol. My function was based on the format of the earlier samples with a single space only.

BTW, when posting XL2BB with all those irrelevant columns, hide them in your worksheet first. :)
 
Upvote 0
Solution

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
BY
=GetName($H1,COLUMNS($BY:BY))

BZ
=GetName($H1,COLUMNS($BY:BZ))

CA
=GetName($H1,COLUMNS($BY:CA))

and so on
 
Upvote 0
Not sure, but after I saved the work book. the #name? error was back
 
Upvote 0
Not sure, but after I saved the work book. the #name? error was back
Did you save it at *.xlsm?

Can you post an image like this that clearly shows
  1. The workbook name (mine is Keebler.xlsm)
  2. The module with the code where the module name is shaded light grey
  3. The function code
1638621735258.png
 
Upvote 0
I like how clean the function would be, if i can figure out what I did to mess it up,
Ive now got the function to produce 2 names... the 3rd name is still illusive
CHRISTMAS MOVIES DB.xlsm
BXBYBZ
350Katie BaileyCindy Leclerc 
0DATA0
Cell Formulas
RangeFormula
BX350:BZ350BX350=GetName($H350,COLUMNS($BY:BY))
 
Upvote 0
Just thought of another way you could get #NAME? error.
If you named the module the same as the function name, that would cause the error too.

1638622000905.png



Looks like you have it working again now though?

Regarding that third name: Do you really want that name to have two spaces in it?
 
Upvote 0
Regarding that third name: Do you really want that name to have two spaces in it?
Assuming that the answer is "no", try adding this extra line into the code.

Rich (BB code):
Function GetName(s As String, n As Long) As String
  s = Application.Trim(s)
  With CreateObject("VBScript.RegExp")
    .Global = True
    .Pattern = "[A-Z][^ ]*?[a-z] [A-Z].+?[a-z](?=([A-Z][^A-Z]{2})|$)"
    If n - 1 < .Execute(s).Count Then GetName = .Execute(s)(n - 1)
    .Pattern = "[A-Z]"
    If Len(GetName) > 0 And .Execute(GetName).Count <> 2 Then GetName = GetName & "*"
  End With
End Function
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

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