Pages

Monday, September 20, 2010

How do you capitalize letters in a name with Excel VBA macro?

Is it possible to have a VBA macro capitalize the first letters in someone's name? For example, if a name is John Stoneburner and a user only enters "john stoneburner' in a text box could it would automatically capitalize it to be John Stoneburner. With Excel, anything is possible! There are two options you could try:

Dim myString as String
myString = Application.WorksheetFunction.Proper(TextBox1.Value)

Or use this option:

Range("A1") = UCase(Left(Range("A1"), 1)) & Mid(Range("A1"), 2)

No comments:

Post a Comment

I'd love to hear from you!
-Nick