Search
Close this search box.

VBA – UCase String


The UCase function in VBA converts all lowercase letters within a string to uppercase letters.

Syntax:

UCase(string)

Parameter:

 

  • string: The string whose lowercase letters you want to convert to uppercase.


Return Value:

  • String: Returns the original string with all lowercase letters converted to uppercase.

 

Example

				
					Dim str1 As String
Dim upperCaseStr As String

str1 = "Hello, World!"
upperCaseStr = UCase(str1) 

' upperCaseStr will be "HELLO, WORLD!"
				
			

Use Cases:

  • Case-Insensitive Comparisons:
    • Comparing strings without regard to case.
    • Searching for strings regardless of their case.
  • Data Normalization:
    • Converting strings to a consistent uppercase format for data entry or analysis.
    • Creating unique identifiers or codes.
  • Database Queries:
    • Creating case-insensitive search criteria in database queries.

Key Considerations:

  • Only lowercase letters are converted to uppercase.
  • Uppercase letters, numbers, and other characters remain unchanged.