Excel VBA UCase Function

Ucase in VBA is an inbuilt function which is used to convert an input string provided to it in the uppercase, it takes a single argument which is the string as an input and the output generated by this function is a string, the one thing to keep in mind is that this function converts all the function to uppercase, not just the first character.

There are situations where we need to convert some of the text values to UPPERCASE in ExcelUPPERCASE In ExcelThe Uppercase function in Excel generates an upper-case version of any text in your spreadsheet. Punctuation and numerical values are unaffected while employing the upper case formula.read more. This can be done by using an UPPER function in regular worksheet function and UCase function in VBA code.

If you are already searching for the UPPER function in VBA, then you will not find it, not even with the worksheet function class. In VBA, it is a completely different and short name function ,i.e. “UCASE.” Here “U” stands for “UPPER,” so the formula reads “UPPERCASE.”


You are free to use this image on your website, templates etc, Please provide us with an attribution linkHow to Provide Attribution?Article Link to be Hyperlinked
For eg:
Source: VBA UCase (wallstreetmojo.com)


Now, look at the syntax of the UCASE function.


String: It is nothing but what is the text value we are trying to convert to Uppercase. This could be a direct value or cell referenceCell ReferenceCell reference in excel is referring the other cells to a cell to use its values or properties. For instance, if we have data in cell A2 and want to use that in cell A1, use =A2 in cell A1, and this will copy the A2 value in A1.read more as well. We will see both kinds of examples in a short while.

How to Convert Text to Uppercase using VBA Ucase?

You can download this VBA UCase Excel Template here – VBA UCase Excel Template

Example #1

Let’s try to convert the text value excel VBA to uppercase text by using the UCase function.

Step 1: Start the subprocedure by creating the macro.


Sub UCase_Example1()

End Sub
Create Subprocedure

Step 2: Declare the variable as VBA String.


Sub UCase_Example1()

Dim k As String

End Sub
Declare Varaiable - 1.2

Step 3: Assign the value to the variable “k” by applying the “UCASE” function.

Open Function 1.3

Step 4: Here, a string is our targeted text value that we are trying to convert to uppercase, and the string value is “excel VBA.”


Sub UCase_Example1()

Dim k As String

K = UCase ("excel vba")

End Sub
Excel vba ucase example 1.4

Step 5: Let’s display the result of the variable in the message box.


Sub UCase_Example1()

Dim k As String

k = UCase("excel vba")

MsgBox k

End Sub
vba uppercase example 1.5

Ok, we are done with the VBA codingVBA CodingVBA code refers to a set of instructions written by the user in the Visual Basic Applications programming language on a Visual Basic Editor (VBE) to perform a specific task.read more part. Let’s run the macro to see the result in a message box.

vba uppercase example 1.6

So Uppercase function converted the text value “excel VBA” to “EXCEL VBA” in a matter of a fraction of seconds.

Example #2

Let’s look at the example of using a cell reference to the function. The same text value I have entered in the cell A1.

vba uppercase example 2.1

Step 1: We will show the result in Range B1 cell, so the code will be Range (“B”).Value =


Sub UCase_Example2()

Range("B1").Value =

End Sub
vba uppercase example 2.2

Step 2: In cell B1 through the UCASE function, we will store the data, so open the UCASE function.

vba uppercase example 2.3

Step 3: Here, the string value is cell reference this time. So give the cell reference as Range (“A1”).Value.


Sub UCase_Example2()

Range("B1").Value = UCase(Range("A1").Value)

End Sub
uppercase example 2.4

So, done.

Run the code and see the result in the B1 cell.

uppercase example 2.5

Example #3

In the above example, we have seen the only single-cell value to be converted to upper case. Imagine if you have several names like the below image.

UCase Example 3.1

In these cases, we cannot keep writing the code for every single line, so we need to enclose the formula with loops. The below code will convert the above text values to the upper case all at once.


Sub UCase_Example3()

Dim k As Long

For k = 2 To 8
Cells(k, 2).Value = UCase(Cells(k, 1).Value)
Next k

End Sub
UCase Example 3.2

This will convert all the text values to the upper case from row 2 to row 8 as follows.

Ucase - 3.3

Imagine if you wish to convert all the selected cell values to the upper case then use the below code.


Sub UCase_Example4()

Dim Rng As Range
Set Rng = Selection

For Each Rng In Selection
Rng = UCase(Rng.Value)
Next Rng

End Sub
Ucase Example 3.4

For this code to work, first we need to select the range of cells we wish to convert to upper case, then run the macro. In the selected range only, it will convert the text values to upper case characters.

Recommended Articles

This has been a guide to VBA UCase. Here we discuss how to convert text to Uppercase in excel VBA along with practical examples and a downloadable excel template. Below are some useful articles related to VBA –

  • 3 Courses
  • 12 Hands-on Projects
  • 43+ Hours
  • Full Lifetime Access
  • Certificate of Completion