Auto Proper Case in a cell

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
618
Office Version
  1. 365
Platform
  1. Windows
Hi
Is there a way to have a Row (C) to default to proper case?
Roc (C) will always be a string.
I was thinking of using an event change macro but anything above the new entry would already be in proper case and wouldn't the wait time be long when i'm down to, say C900?
I tried Data Validation, but it only alerts if the the string is not in proper case. it doesn't change the string.
What I use now is the following macro:
VBA Code:
Sub Propercase()     
Dim c As Range
For Each c In Selection
    c.Value = StrConv(c.Value, vbProperCase)
Next c
End Sub
After I type the string, I have an icon on the ribbon to change the case. I would like to have it change when i leave the cell

mike
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,767
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Try using this...it needs to be pasted into the Sheet module
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
    Application.EnableEvents = False
    Target.Value = StrConv(Target.Value, vbProperCase)
    Application.EnableEvents = True
End If
End Sub
 
Solution

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,718
Office Version
  1. 2010
Platform
  1. Windows
Try using this...it needs to be pasted into the Sheet module
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
    Application.EnableEvents = False
    Target.Value = StrConv(Target.Value, vbProperCase)
    Application.EnableEvents = True
End If
End Sub
I would suggest replacing the red-highlighted line of code with this one...

Target.Value = Application.Proper(Target.Value)

as Excel's Proper function is better than VBA's version. For example, it handles text after dashes or opening parentheses better.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,416
Messages
5,601,550
Members
414,458
Latest member
mekhallet salah

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
Top