Change all to proper case using VBA - Office 365

Ichokuchi

New Member
Joined
Jul 6, 2018
Messages
37
Ok so I am trying to automatically have my form in excel change things to proper case when entered. I found a code that works but then seems to crash excel or kick me to debug here is what I have please help in fixing it so it works.

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140603
Target.Value = Application.WorksheetFunction.Proper(Target.Value)
End Sub


- The line that when i go to debug that seems to be the issue is this one: Target.Value = Application.WorksheetFunction.Proper(Target.Value)


Please help! Thanks!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Application
        .EnableEvents = False
        Target.Value = .WorksheetFunction.Proper(Target.Value)
        .EnableEvents = True
    End With
End Sub

Explanation
Disabling "Events" prevent a change made by the code from triggering a fresh "Event"
 
Upvote 0
Is it an actual UserForm or a cell on the worksheet ??
If the code is in the sheet module and it is a cell on the worksheet it works fine for me !!

Also, this code won't work if you try to apply it to multiple cells at a time !!....use one cell at a time
 
Upvote 0
It's a form with several cells and it works on all of them until I tried to erase anything then it errors up. But maybe with code from above I will not get anymore errors
 
Upvote 0
If you still get that problem... try this ... but should not be necessary

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
[COLOR=#ff0000]If Target.Value = vbNullString Then Exit Sub[/COLOR]
    With Application
        .EnableEvents = False
        Target.Value = .WorksheetFunction.Proper(Target.Value)
        .EnableEvents = True
    End With
End Sub
 
Last edited:
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Application
        .EnableEvents = False
        Target.Value = .WorksheetFunction.Proper(Target.Value)
        .EnableEvents = True
    End With
End Sub

Explanation
Disabling "Events" prevent a change made by the code from triggering a fresh "Event"


Ok I tried that and I still get the debug/end window popping up.
 
Upvote 0
If you still get that problem... try this ... but should not be necessary

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
[COLOR=#ff0000]If Target.Value = vbNullString Then Exit Sub[/COLOR]
    With Application
        .EnableEvents = False
        Target.Value = .WorksheetFunction.Proper(Target.Value)
        .EnableEvents = True
    End With
End Sub

So I tried this, and I don't get debug window, it also doesnt change my things to Proper so seems a step back lol.
 
Upvote 0
I need to understand EXACTLY how cells are being updated

1. Which version of Excel are you using?
2. Please post your userform code using code tags
- to post code click on # icon above post window and paste your code BETWEEN the code tags

thanks
 
Upvote 0
I need to understand EXACTLY how cells are being updated

1. Which version of Excel are you using?
2. Please post your userform code using code tags
- to post code click on # icon above post window and paste your code BETWEEN the code tags

thanks
I am using office 365, I'm confused what is a userform code? cells are being updated by clicking in the part of the form needs updated, and typing or pasting into. the original code worked changing things to proper, but if I clear contents or anything it brings up the end/debug window. I'm trying to eliminate that from happening if I were the only one using this form it wouldnt matter.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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