Vba Code to Change Case

katkth7533

New member
Joined
Jul 29, 2014
Messages
17
Reaction score
0
Points
0
Hi there. I'd like to add a code to an Excel spreadsheet so that when users enter data in a certain range ("E3:E25"), the data changes to Title Case regardless of what they enter. I don't want to use data validation rules in the cells or have to run a macro after data is entered. All the coding I could think of would apply to the entire worksheet but I need to limit it to these cells.

Thanks
 
Add this to the worksheet code module

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)


    On Error GoTo ws_exit
    
    Application.EnableEvents = False
    
    If Not Intersect(Target, Me.Range("E3:E25")) Is Nothing Then
    
        Target.Value = Application.Proper(Target.Value)
    End If


ws_exit:
    Application.EnableEvents = True
End Sub
 
Back
Top