VBA UCASE Function

VBA UCase Function in Excel

VBA UCase function in Excel is categorized as a Text/String function in VBA. It is a built-in function in MS Office Excel. It converts a string to Upper case text. It has one mandatory String parameter. If input string has Null, then Null is returned as output.

We use only in VBA function. We can’t use this function in Excel worksheet. The VBA UCase function can use in either procedure or function in a VBA editor window in Excel. We can use this VBA UCase function any number of times in any number of procedures or functions. In the following section we learn what is the syntax and parameters of the UCase function, where we can use this VBA UCase function and real-time examples.

Syntax of VBA UCase Function

The syntax of the VBA UCase function is

UCase (String)

Note: This UCase function returns a string in Upper case letters.

Parameters or Arguments

There is one mandatory parameter or argument for the UCase Function.
Where
string: The string is a mandatory argument. The string which we want to convert to Upper case letters.

Where we can apply or use the VBA UCase Function?

We can use this VBA UCase function in MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

Example 1: Convert “awesome” string to Upper case letters

Here is a simple example of the VBA UCase function. This below example macro convert given string to Upper case letters.

'Convert "awesome" string to Upper case  letters.
Sub VBA_UCase_Function_Ex1()

    Dim sString As String, sSubString As String
    
    sString = "awesome"
    
    sSubString = UCase(sString)
    
    MsgBox "The given string in upper case is :" & sSubString, vbInformation, "VBA UCase Function"

End Sub

Output: Here is the screen shot of the first example output.
VBA UCASE Function

Example 2: Convert “WELCOME” string to Upper case letters

Here is a simple example of the VBA UCase function. This below example macro does not affects on Upper case letters.

'Convert "WELCOME" string to Upper case  letters.
Sub VBA_UCase_Function_Ex2()

    Dim sString As String, sSubString As String
    
    sString = "WELCOME"
    
    sSubString = UCase(sString)
    
    MsgBox "The given string in upper case is :" & sSubString, vbInformation, "VBA UCase Function"
    
End Sub

Output: Here is the screen shot of the second example output.
VBA UCASE Function

Example 3: Convert “Test 1234 – # $” string to Upper case letters

Here is a simple example of the VBA UCase function. This below example macro does not affects for Upper case letters, Numbers and Special characters.

'Convert "Test 1234 - # $" string to Upper case  letters.
Sub VBA_UCase_Function_Ex3()

    Dim sString As String, sSubString As String
    
    sString = "Test 1234 - # $"
    
    sSubString = UCase(sString)
    
    MsgBox "The given string in upper case is :" & sSubString, vbInformation, "VBA UCase Function"
    
End Sub

Output: Here is the screen shot of the third example output.
VBA UCASE Function

Example 4: Convert Null string to Upper case letters

Here is a simple example of the VBA UCase function. This below example macro returns Null, because specified string contains a Null.

'Convert specified string to Upper case  letters.
Sub VBA_UCase_Function_Ex4()

    Dim sString As String, sSubString As String
    
    sString = ""
    
    sSubString = UCase(sString)
    
    MsgBox "The given string in upper case is :" & sSubString, vbInformation, "VBA UCase Function"
    
End Sub

Output: Here is the screen shot of the fourth example output.
VBA UCASE Function

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

Leave a Reply