Auto Proper Case in a cell

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
774
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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0
Solution
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.
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

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
Back
Top