VBA code to capitalize each word of a string [Excel]

Below is the Excel VBA code to capitalize each word of a string.

Sub capitalizeEachWordOfString()
'macro to capitalize each word of a string
exString = "helLo how Are yOU" ' Example string
stringAfterCapitalized = StrConv(exString, vbProperCase) ' capitalizing each word of the string
MsgBox ("string after its each word is capitalized is - " + stringAfterCapitalized)
End Sub

Output:

capitalize-each-word-string-VBA-excel

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published.