VBA: Force Proper, Upper, or Lower case automatically

August 14th, 2004 | Categories: Strings | Tags: , , ,

Do you need to automatically change a cells text to Proper, Upper, or Lower case after the user enters it? There are multiple way to accomplish this, and multiple requirements possible. Here is an example that automatically changes everything after it’s entered in a particular column. Hopefully you can build from this example!

1. Press ALT and F11 to open the code window
2. Double click the sheet name you want to automatically
change case
3. Put this code in the code window:

Code for Proper case

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Application.EnableEvents = False
If Target.Column = 5 Then
Target = StrConv(Target, vbProperCase)
End If
Application.EnableEvents = True

End Sub

For Upper case you can change

StrConv(Target, vbProperCase)

to

Ucase(Target)

For Lower case you can change

StrConv(Target, vbProperCase)

to

Lcase(Target)

Get LIVE Help
Custom Excel solutions & live Excel help!
► Go to www.ExcelAutomationHelp.com
► Email Now@ExcelAutomationHelp.com
  1. March 4th, 2010 at 14:11
    Reply | Quote | #1

    I wonder if it is possible to just do according to the following

    range(“a1″).text(uppercase)=true or something like that??