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!
 
That is what is going on, so any ideas? I merged cells on the sample sheet and i get that error.
Yongle you are a rockstar in helping me figure out the problem, to work with merged cells I used this.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target(1).Value = vbNullString Then Exit Sub
With Application
.EnableEvents = False
Target(1).Value = .WorksheetFunction.Proper(Target(1).Value)
.EnableEvents = True
End With
End Sub

You see i added (1) after target before the . and it works!
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Well done! Merged cells cause lots of problems with VBA - avoid using them if possible. Thanks for the feedback :beerchug:

One final comment
- please use code tags when posting code - it is easy - click on # icon above post window and paste your code BETWEEN the code tags.
 
Last edited:
Upvote 0
AND...instead of using merged cells, format the multiple cells by....
Highlight the cells
Rclick Format cells
alignment tab
Horizontal dropdown
Center across selection

They will then look like they are merged
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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