Capitalize the first letter in each word on a userform text box

Jesienouski

New Member
Joined
Mar 9, 2011
Messages
14
I'm trying to put together a userform that has multiple text boxes on it and I'd like to have the form auto capitalize the first letter in each word of the various text boxes. Some of the words in the text boxes will contain numbers, just as a heads up. I've searched and cannot find anything that I can get to work. Below is the code I have started, but I have no idea if it is even in the ballpark. If I can put together a sub that will do all the boxes at once instead of the individual fields that would be great, what I have started was one of the fields. Please help :)

Code:
Private Sub B1FirstName_Change()
    Dim x As Range
    'This will make the first letter of the text within any selection of
    'cells uppercase.
    For Each x In Selection
        x.Value = StrConv(x.Value, vbProperCase)
    Next x
    
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I found it, it may not be the best way to do this, but this seems to work

B1FirstName.Value = Application.WorksheetFunction.Proper(B1FirstName.Value)
Hooray!

I guess that if I had really studied the reply above it would have worked a lot sooner :(
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

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