How do I convert strings to upper case using VBA?

To convert strings to upper case using VBA, you can use the UCase() function. This function takes a string as an argument and returns the same string with all characters converted to uppercase. For example, the function UCase(“Hello World”) returns “HELLO WORLD”. You can also use the StrConv() function to convert strings to upper case. This function takes a string and a conversion type as arguments. The conversion type for converting to upper case is vbUpperCase. For example, the function StrConv(“Hello World”, vbUpperCase) returns “HELLO WORLD”.


You can use the UCase function in VBA to convert strings to uppercase.

You can use the following syntax to convert a range of cells with strings to uppercase:

Sub ConvertToUpperCase()
    
    Dim i As Integer

    For i = 2 To 10
        Range("B" & i) = UCase(Range("A" & i))
    Next i
    
End Sub

This particular example will convert each string in the range A2:A10 to uppercase and display the results in the range B2:B10.

The following example shows how to use this syntax in practice.

Example: Convert Strings to Uppercase Using VBA

Suppose we have the following column of strings in Excel:

Suppose we would like to convert each string in column A to uppercase and display the results in column B:

We can create the following macro to do so:

Sub ConvertToUpperCase()
    
    Dim i As Integer

    For i = 2 To 10
        Range("B" & i) = UCase(Range("A" & i))
    Next i
    
End Sub

When we run this macro, we receive the following output:

Column B displays each string in column A in uppercase.

Note: You can find the complete documentation for the UCase function in VBA .

x