How to use VBA UCASE Function in Excel

In simple words, when you specify a text into it, it returns that text by converting its each character into the capital letter.

If a text is already in the upper case, that remains unchanged.

Syntax

UCase(String)

Example

In the below example, we have a lower case text string in cell A1.

vba ucase function example text converted into upper case

To convert this text into a upper case text you can UCASE function like below.

Sub UpperCase()
Range("A1").Value = UCase(Range("A1"))
End Sub
vba ucase function example cell text

You can also write this code like below to remove space from the active cell.

ActiveCell.Value = UCase(ActiveCell.Value)

And, to convert a text into an upper case from all the cells in a selection then you can use below code.

Sub UpperCase()
Dim rng As Range
For Each rng In Selection
rng = UCase(rng)
Next rng
End Sub

Related Tips

  1. Top 100 Ready to Use Macro Codes
  2. How to Convert to Sentence Case in Excel
  3. UPPER Function [Worksheet]