I wanted to write a function to capitalize the first character of every word. For example, I want to change "cell address" to "Cell Address". Before I started the function, I was thinking perhaps there already has a easy way to do that. Luckily, I did a search in the Google and found this: StrConv
This is the function I've written:
There are also vbWide, where values are 4, 8, 16, 32, 64, 128 to convert the string with specific usage. (Please refer to the reference page)
Public Function CapitalizeFirstCharacter(ByVal Value As String) As String
' Make the whole string lower case, then only capitalize the first character
CapitalizeFirstCharacter = StrConv(LCase$(Value), vbProperCase)
StrConv (String, conversion[, LCID])
String - required. String expression to be converted.
conversion - required. Integer. The sum of values specifying the type of conversion to perform.
LCID - optional. The LocaleID, if different than the system LocaleID. (default: system LocaleID)
|vbUpperCase||1||Convert to uppercase|
|vbLowerCase||2||Convert to lowercase|
|vbProperCase||3||Convert the first letter of every word in string to uppercase|