Capitalize first letter of each word

This tutorial shows how to uppercase the first letter of each word from a string through the use of an Excel formula, with the PROPER function, or VBA

EXCEL FORMULA 1. Capitalize first letter of each word using the PROPER function

EXCEL

Hard coded formula
Capitalize first letter of each word
Cell reference formula
Capitalize first letter of each word
=PROPER("bread butter milk")
=PROPER(B5)
GENERIC FORMULA

=PROPER(string)

ARGUMENTS
string: A string of words in which you want to capitalize the first letter of each word.

GENERIC FORMULA

=PROPER(string)

ARGUMENTS
string: A string of words in which you want to capitalize the first letter of each word.

EXPLANATION

This formula uses the PROPER function to uppercase the first letter of each word from a string.

Click on either the Hard Coded or Cell Reference button to view the formula that either has the string that contains the words in which you want to capitalize the first letter of each word entered directly in the formula or referenced to a cell.

VBA CODE 1. Capitalize first letter of each word using VBA

VBA

Hard coded against single cell
Sub Capitalize_first_letter_of_each_word()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'capitalise the first letter of each word in a string
ws.Range("C5") = WorksheetFunction.Proper("bread butter milk")

End Sub

Cell reference against single cell
Sub Capitalize_first_letter_of_each_word()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'capitalise the first letter of each word in a string
ws.Range("C5") = WorksheetFunction.Proper(ws.Range("B5"))

End Sub

Hard coded against range of cells
Sub Capitalize_first_letter_of_each_word()
'declare variables
Dim ws As Worksheet
Dim strString(4) As String
Set ws = Worksheets("Analysis")
strString(0) = "bread butter milk"
strString(1) = "BRead BUtter MIlk"
strString(2) = "BREAD BUTTER MILK"
strString(3) = "breAD buttER miLK"

'capitalise the first letter of each word in a string

For i = 0 To 3
strStringProper = strString(i)
x = 5
x = x + i
ws.Range("C" & x) = WorksheetFunction.Proper(strStringProper)
Next i

End Sub

Cell reference against range of cells
Sub Capitalize_first_letter_of_each_word()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")

'capitalise the first letter of each word in a string

For i = 5 To 8
ws.Range("C" & i) = WorksheetFunction.Proper(ws.Range("B" & i))

Next i

End Sub

RELATED TOPICS

Related Topic Description Related Topic and Description
How to change lowercase into uppercase for a specific text string through the use of an Excel formula or VBA