Tim Hanson
Member
Hello,
I want to convert the Names in a column to proper case but I do not want to change there titles.
The macro converts cell content to proper case up to the first ","
This almost works, but it gives Betty H.Whitney as Betty H.whitney and Hank O'Day as Hank O'day
Is there a way to alter this code to take these into account
Thanks
I want to convert the Names in a column to proper case but I do not want to change there titles.
The macro converts cell content to proper case up to the first ","
BOB FEGESON
Sally Ran, Ph.D.
GREG HYMAN, MA, CPCC
ToSally Ran, Ph.D.
GREG HYMAN, MA, CPCC
Bob Fegeson
Sally Ran, Ph.D.
Greg Hyman, MA, CPCC
Sally Ran, Ph.D.
Greg Hyman, MA, CPCC
This almost works, but it gives Betty H.Whitney as Betty H.whitney and Hank O'Day as Hank O'day
Is there a way to alter this code to take these into account
Thanks
Code:
Sub FindChr()
Dim ws As Worksheet
Dim myRange As Range, cell As Range
Dim tmpString As String
Dim MyString As Variant
Dim i As Long
'~~> Change this to the relevant worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
Set myRange = .Range("D2", .Range("D" & .Rows.Count).End(xlUp))
For Each cell In myRange
If InStr(1, cell.Formula, ",") Then
MyString = Split(cell.Formula, ",")
tmpString = StrConv(MyString(0), vbProperCase)
For i = 1 To UBound(MyString)
tmpString = tmpString & "," & MyString(i)
Next i
cell.Formula = tmpString
Else
cell.Formula = StrConv(cell.Formula, vbProperCase)
End If
Next cell
End With
End Sub