Upper Case Woes

B

Brian Matlack

Hi!

I use the following code to Cause the first (1) letter of an entry i
column C to be Upper case.
Can I modify it to force the first Two (2) characters to be Upper cas
if in fact they are letters? Or do I need a whole new set of code?

<Start Code>
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Auto change to uppercase first letter
On Error GoTo ErrHandler
If Target.Count = 1 And Target.Column = 3 Then
Application.EnableEvents = False
sStr = Target.Value
Target.Value = UCase(Left(sStr, 1)) & LCase( _
Mid(sStr, 2))
End If
ErrHandler:
Application.EnableEvents = True
End Sub
<End Code>

Thanks in advance for any help or suggestions!
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Auto change to uppercase first letter
On Error GoTo ErrHandler
With Target
If .Count = 1 And .Column = 3 Then
Application.EnableEvents = False
.Value = UCase(Left(.Value, 2)) & LCase( _
Mid(.Value, 3, Len(.Value) - 2))
End If
End With
ErrHandler:
Application.EnableEvents = True
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with googlemail if mailing direct)

"Brian Matlack" <[email protected]>
wrote in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top