![](https://codky.com/wp-content/uploads/2024/01/How-to-use-UCase-function-in-VBA-1024x576.png)
Contents
In VBA (Visual Basic for Applications), the UCase function converts a specified string to uppercase.
Basic syntax
VBA
UCase(String)
Where String is the string expression you want to convert to uppercase.
Example
VBA
Sub ConvertToUppercase()
Dim originalText As String
Dim uppercaseText As String
originalText = "Hello, World!" ' Input string
uppercaseText = UCase(originalText) ' Convert to upper case
MsgBox uppercaseText ' Display the result in a message box
End Sub
The UCase function is useful when you want to perform case-insensitive string comparisons or ensure that text is formatted consistently in uppercase. Remember that UCase will not modify any non-letter characters, so numbers, punctuation, and spaces will be unaffected.
Note that VBA also has the opposite function called LCase which converts text to lowercase.