Video: Change case in Excel

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Watch how to create a macro that changes the case of text in multiple cells at once. By copying and pasting the following Visual Basic for Applications (VBA) code into the Visual Basic Editor in Excel, you can run this macro on your own computer.

Sub ChangeTextCase()

Dim strChange As String

strChange = InputBox("Type l, u, or p to change case:" & vbCr & vbLf & vbCr & vbLf & _
"Lowercase = l, uppercase = u, proper case = p", "Change case of selected cells", "")

Select Case strChange

Case "l", "L"
For Each x In Application.Selection
x.Value = LCase(x.Value)
Next

Case "u", "U"
For Each x In Application.Selection
x.Value = UCase(x.Value)
Next

Case "p", "P"
For Each x In Application.Selection
x.Value = WorksheetFunction.Proper(x.Value)
Next

Case Else
MsgBox "Type l, u, or p." & vbCr & vbLf & vbCr & vbLf & "Click OK to start over."

End Select

End Sub
Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×