All Caps to Proper Case

amerifax

Board Regular
Joined
Dec 17, 2008
Messages
247
Does anyone out there having a solution for working with a name field. I have to convert all caps to proper. I have many of the typical problems associated with names. Here are a few:

Mc, Mac, Jr, I, II, one initial, two initial, LA, O'

There are so many I'm kind of drawing a blank tonight but I think you get the idea. This is how the data looks.

WALDORF ROBERT & VICKIE
ELKINS C
VETTER M M
FERBER-STUMPF JANELLE

It's a big project, but I was is hoping that maybe somebody has already done this dance and has it available.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
That I had. And it tells you straight out that it can't deal we conditions such as O'Neal, McDonald, I, II, la and so many more. Especially since the data fields, many, are 250,000 plus.
 
Upvote 0
How about applying the PROPER function and then writing a piece of code to catch the exceptions?

Something like this:-
Code:
[FONT=Fixedsys]Option Explicit[/FONT]
 
[FONT=Fixedsys]Public Function ProperName(ByVal argName As String) As String[/FONT]
 
[FONT=Fixedsys] Dim iPtr As Integer[/FONT]
 
[FONT=Fixedsys] ProperName = " " & Application.WorksheetFunction.Proper(argName) & Space(3)[/FONT]
 
[FONT=Fixedsys] For iPtr = 1 To Len(ProperName)[/FONT]
[FONT=Fixedsys]   Select Case True[/FONT]
[FONT=Fixedsys]     Case Mid(ProperName, iPtr, 2) = "Mc"[/FONT]
[FONT=Fixedsys]       ProperName = Left(ProperName, iPtr + 1) & UCase(Mid(ProperName, iPtr + 2, 1)) & Mid(ProperName, iPtr + 3)[/FONT]
[FONT=Fixedsys]     Case Mid(ProperName, iPtr, 2) = "O'"[/FONT]
[FONT=Fixedsys]       ProperName = Left(ProperName, iPtr + 1) & UCase(Mid(ProperName, iPtr + 2, 1)) & Mid(ProperName, iPtr + 3)[/FONT]
[FONT=Fixedsys]     Case Mid(ProperName, iPtr, 3) = "Mac"[/FONT]
[FONT=Fixedsys]       ProperName = Left(ProperName, iPtr + 2) & UCase(Mid(ProperName, iPtr + 3, 1)) & Mid(ProperName, iPtr + 4)[/FONT]
[FONT=Fixedsys]   End Select[/FONT]
[FONT=Fixedsys] Next iPtr[/FONT]
 
[FONT=Fixedsys] ProperName = Trim(ProperName)[/FONT]
 
[FONT=Fixedsys]End Function[/FONT]

Paste into a new general code module. Test in your worksheet like this: =ProperName("FRED MCMURRAY") or =ProperName(A1), or in the VBA Immediate window like this: ?ProperName("barack machussein o'bama").

Extra conditions can be added to the code as required.

Any good?
 
Last edited:
Upvote 0
I had this trouble when I was working on a data cleaning exercise. I know its a bit crude but I used the find and replace tool to fix the obvious errors created by the PROPER function. Sorry I couldn't be of more use
 
Upvote 0
willcass

I will upload the completed file when done. Also do you have a list on the problem name, such as Mc, O' and so many more.
 
Upvote 0
To All

There are to ways to respond to a message.
1. Quick that is a button on a particular response.
2. As I'm doing here "Replay to Thread"

Question!
Method 2
If sent to "quick response", button on the actual message, well this alert the author. In other words will I not need to inter the name of the message's author. I do it times want to direct the response to a certain person. This would not be a personal responce but just giving the author a HEY.

I run this same board and I would like my board to respond to messages as I think it can
 
Upvote 0
Hi there,

Here is a macro version to do what you want:

Rich (BB code):
Rich (BB code):
Rich (BB code):
Sub TitleCase()
Dim cell As Range
For Each cell In Selection.Cells
If cell.HasFormula = False Then
cell = Application.Proper(cell)
End If
Next
End Sub 


From what i have tested, the only thing it wont pick up correctly is Mc (i.e. McDonalds) and II (i.e. Edward Hammond II)

Just select all the cells you want to convert and then run the macro.

Hope it helps :)

Cheers
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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