Capitilization After Special Character

JarekM

Board Regular
Joined
Nov 13, 2018
Messages
86
Hi,

I have made a code where if I were to write out a name in a textbox the first letter will be capitalized. It also capitalizes the first letter whenever I add a space between names.
So, I am having this problem where whenever I put a special character or a number (For ex. !,@,#,$,%,&,*,.,/,1,2,3etc...) but no space after the special character, the first letter of the name or word isn't capitalized. I would like to have that first letter of the word capitalized.

Here is an example:

John Snow

The J in John will be capitalized and after the space the S in Snow will also be capitalized.


But if I were to add a special character or a number, like below:

2323 N.farvalley

The N will be capitalized, but the F in Farvalley won't because I didn't add a space.


I would also like this function to be a universal code and have it work for all textboxs and not just one.



Thank you in advance
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How are you currently doing the capitalisation?
 
Upvote 0
Hi,

here is the code that i am using:
Code:
Private Sub TextBox1_Change()
TextBox1.Text = StrConv(TextBox1.Text, 3)
End Sub

Thanks
 
Upvote 0
Hi,

here is the code that i am using:
Code:
Private Sub TextBox1_Change()
  [B][COLOR="#FF0000"]TextBox1.Text = StrConv(TextBox1.Text, 3)[/COLOR][/B]
End Sub
Excel's PROPER function is much better than VB's... try it this way...

TextBox1.Text = Application.Proper(TextBox1.Text)
 
Last edited:
Upvote 0
Thank you!

It works wonderfully, but I have one more question.

How can I change the code, so every letter before a special character is capital?

Here is an example:
Kert2323

It originally capitalizes the K by default, but I would also like to have the code capitalize every other letter that is before the numbers and/or special character?

Thank you again
 
Upvote 0
THow can I change the code, so every letter before a special character is capital?

Here is an example:
Kert2323

It originally capitalizes the K by default, but I would also like to have the code capitalize every other letter that is before the numbers and/or special character?
Do you mean you want every letter capitalized? If so...

TextBox1.Text = UCase(TextBox1.Text)

If not, you will need to explain what you want in more detail (give examples of text that meet the criteria and text that does not meet the criteria).
 
Upvote 0
I want all of the letters before the special characters to be capitalized.

Example:
Kert-2323 Fly, Kert7683 Fly, Kert/9029 Fly


Instead of that I want this:
KERT-2323 Fly, KERT7683 Fly, KERT/9029 Fly

Every letter before the numbers and special characters are capitalized, but Fly stays the same, I don't want its letters capitalized.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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