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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Well done! Merged cells cause lots of problems with VBA - avoid using them if possible. Thanks for the feedback (y)

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,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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