modify code to make all words Proper case , not just all Upper case

steve400243

Active Member
Joined
Sep 15, 2016
Messages
429
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello, I use this code to make all letters capitol letters, Need to modify it so that it changes all words to proper case. I cannot figure it out with multiple google searches.

For instance HAPPY DAYS to Happy Days. Thanks for your help forum Experts.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell   As Range
    On Error Resume Next
    Application.EnableEvents = False
    For Each cell In Target
        cell = vbProperCase(cell)
    Next
    Application.EnableEvents = True
End Sub


Sub RunOnce()
Dim c As Range
Application.ScreenUpdating = False
For Each c In ActiveSheet.UsedRange
    c = vbProperCase(c)
Next
Application.ScreenUpdating = True
End Sub
 
Thank you again Rick, I have it running with your code now, and it works great. I really appreciate the tips! Have a nice Day
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Proper case code not working correctly

Hello, I keep getting an error code with code to make everything Proper case? Any ideas. I need it to exclude Column A and B

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell   As Range
    On Error Resume Next
    Application.EnableEvents = False
    For Each cell In Target
      If cell.Column <> 1 Then
      If cell.Column <> 2 Then
        cell.Value = Application.Proper(cell.Value)
      End If
    Next
    Application.EnableEvents = True
 
Upvote 0
Re: Proper case code not working correctly

What happens if you change

Code:
For Each cell In Target
      If cell.Column <> 1 Then
      If cell.Column <> 2 Then
        cell.Value = Application.Proper(cell.Value)
      End If
    Next

to


Code:
     If Target.Column > 2 Then Target.Value = Application.Proper(Target.Value)

Else remove/comment out your error handler, post what your error says and on what line.
Although your error is probably because you are missing an End If
 
Last edited:
Upvote 0
Re: Proper case code not working correctly

That gives me - "compile error End if without block if"
 
Upvote 0
Re: Proper case code not working correctly

That gives me - "compile error End if without block if"

It can't give you that error it is all one line and as I and the next post stated you are missing an End If in your original code.
 
Last edited:
Upvote 0
Re: Proper case code not working correctly

sorry for not understanding this Mark, but I cant get it to work. So much to learn. This code below, provided by Mr Rothstein, works fine for excluding col B, I need it to also exclude column A?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell   As Range
    On Error Resume Next
    Application.EnableEvents = False
    For Each cell In Target
      If cell.Column <> 2 Then
        cell.Value = Application.Proper(cell.Value)
      End If
      Next
 Application.EnableEvents = True
 End Sub
 
Upvote 0
Re: Proper case code not working correctly

I have merged your two threads together.

Please do NOT start a new thread on the same question. Since it has to do with the original solution provided to you, just continue on in that thread (that way, those who came up with the solution can help you adjust/tweak/debug it).
 
Upvote 0
Re: Proper case code not working correctly

I have merged your two threads together.

Please do NOT start a new thread on the same question. Since it has to do with the original solution provided to you, just continue on in that thread (that way, those who came up with the solution can help you adjust/tweak/debug it).

Thanks Joe4, wasn't sure about that, so just started the new one. Appreciate the tip.
 
Upvote 0
Re: Proper case code not working correctly

sorry for not understanding this Mark, but I cant get it to work. So much to learn. This code below, provided by Mr Rothstein, works fine for excluding col B, I need it to also exclude column A?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell   As Range
    On Error Resume Next
    Application.EnableEvents = False
    For Each cell In Target
      If cell.Column [COLOR="#FF0000"][B]>[/B][/COLOR] 2 Then
        cell.Value = Application.Proper(cell.Value)
      End If
      Next
 Application.EnableEvents = True
 End Sub
 
Upvote 0

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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