event macro to change text to proper case

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi

I use this event macro to change the text to proper case.
I had to use an ‘s for the first time. It changed the ‘s to proper case
Example:
type in dave’s macro will change it to Dave’S after I hit enter

How do I change the macro to keep the ‘s in lower case

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
Application.EnableEvents = False
Target.Value = Application.Proper(Target.Value)
Application.EnableEvents = True
End If
End Sub

mike
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 3 Then
        Application.EnableEvents = False
        Target.Value = WorksheetFunction.Substitute(WorksheetFunction.Proper(WorksheetFunction.Substitute(Target, "'", "z-z")), "z-Z", "'")
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
Solution
I think changing your main line of code to this should also work...
VBA Code:
Target.Value = Replace(Application.Proper(Target.Value), "'S", "'s")
 
Upvote 0
opps i didn't see your reply, Rick, until i hit post reply for mumps.
thanks,

mike
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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