-
If it is just Mcs and Macs you wish to capitalise then this should do it. However not all suffixes are capitalised. Macdonald is also valid.
[VBA]Option Explicit
Option Compare Text
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim t
t = TextBox1
If Left(t, 2) = "mc" Then
t = UCase(Left(t, 1)) & "c" & UCase(Mid(t, 3, 1)) & Right(t, Len(t) - 3)
ElseIf Left(t, 3) = "mac" Then
t = UCase(Left(t, 1)) & "ac" & UCase(Mid(t, 4, 1)) & Right(t, Len(t) - 4)
Else
t = UCase(Left(t, 1)) & Right(t, Len(t) - 1)
End If
TextBox1 = t
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules