×

Excel VBA StrConv Function

The StrConv function in VBA converts a string into a specified format.

Syntax

StrConv (String, Conversion, [LocaleID])

Parameter

String (required) – This parameter represents the string to be converted.

Conversion (required) – This parameter specifies the type of conversion.

It can have any of the following values:

  • vbUpperCase
  • vbLowerCase
  • vbProperCase
  • vbWide
  • vbNarrow
  • vbKatakana
  • vbHiragana
  • vbUnicode
  • vbFromUnicode

LocaleID (optional) – This parameter specified the LocaleID. It uses the system LocaleID as the default value.

Return

This function returns a string after converting it to a specified format.

Example 1

Sub StrConv_Example1()
 'Converting the String "Hello VBA" to upper case with StrConv function.
 Dim str As String
 Dim text As String
 text = "Hello VBA"
 str = StrConv(text, vbUpperCase) 
 'Converting the String "Hello VBA" to upper case with StrConv function.
 Dim str As String
 Dim text As String
 text = "Hello VBA"
 str = StrConv(text, vbUpperCase)
 ' The variable will return "HELLO VBA".
 Cells(1, 1).Value = str
 End Sub 

Output

HELLO VBA
VBA StrConv Function

Example 2

Sub StrConv_Example1()
 'Coverting the String "Hello VBA" to lower case with StrConv function.
 Dim str As String
 Dim text As String
 text = "Hello VBA"
 str = StrConv(text, vbLowerCase)
 ' The variable will return "hello vba". 
 Cells(1, 1).Value = str
 End Sub 

Output

Hello vba
VBA StrConv Function2

Example 3

Sub StrConv_Example1()
 'Coverting the String "Hello VBA" to proper case with StrConv function.
 Dim str As String
 Dim text As String
 text = "Hello VBA"
 str = StrConv(text, vbProperCase)
 ' The variable will return "Hello Vba".
 Cells(1, 1).Value = str
 End Sub 

Output

Hello Vba
VBA StrConv Function3

Related Topics

VBA runtime error 1004

What is 1004 error?  VBA 1004 Error, also known as object-defined or application-defined, is a runtime error in VBA, usually, if the specified range does not exist in the worksheet or if the Application...

6 minutes read.

Excel VBA WeekdayName Function

Excel VBA WeekdayName Function: The WeekdayName function in VBA returns a string containing the weekday name, for the specified integer representation of a weekday. Syntax WeekdayName (Weekday, [Abbreviate], [FirstDayOfWeek]) Parameter Weekday (required) – This parameter represents...

2 minutes read.

VBA Screen Updating

What is VBA Screen Updating property? Screen Updating is a VBA property which is used to display the output generation while running the code. If this property is enabled, we could see...

6 minutes read.

Excel VBA IsError Function

VBA IsError Function: The IsError function in VBA returns a Boolean value showing whether the specified Expression represents an error or not. Syntax IsError (Expression) Parameter Expression (required)- This parameter represents the variant that you...

1 minute read.

Excel VBA- Pivot Table Fields

VBA- Pivot Table Fields: The Pivot Fields collection contains all the fields from the data source, including any calculated fields. The main aspect of adding a field is its Position...

4 minutes read.

For Next loop in VBA

For Next Loop The ”For Next” loop is used for a fixed number of times. It works by implementing the loop for the specified number of times. In this, the user specifies how...

3 minutes read.

Excel VBA IsArray Function

VBA IsArray Function: The IsArray function in VBA returns a Boolean, showing whether the given variable is an Array or not. Syntax IsArray (VarName) Parameter VarName (required)- This parameter represents the variable that you want...

1 minute read.

Excel VBA CVar Function

VBA CVar Function: The CVar function in VBA converts an expression into a Variant data type. Syntax CVar (Expression) Parameter Expression (required) – This parameter represents the expression that that you want to convert...

1 minute read.

VBA Charts

What is a Chart? A chart is used to visually show numbers or data in a spreadsheet (or spread over multiple spreadsheets) so that the end-user can look at the chart...

3 minutes read.

Excel VBA Sqr Function

VBA Sqr Function: The Sqr function in VBA returns the square root for the specified number. Syntax Sqr (Number) Parameter Number (required) – This parameter represents a positive numeric value that you want to calculate...

1 minute read.

Procedures in VBA

Procedures in VBA A procedure is a block of statements or units of computer code that performs some action. It is enclosed with a declaration statement, and its primary purpose is to carry out...

3 minutes read.

VBA ListBox

What is a ListBox? ListBox refers to a permanently displayed control (usually box-shaped) which contains a list of objects (or attribute, or elements) from which the user can select single or multiple attributes....

8 minutes read.

Excel VBA IsEmpty Function

VBA IsEmpty Function: The IsEmpty function in VBA returns a Boolean value showing whether the specified Expression is Empty (variant has not been declared) or not. Syntax IsEmpty (Expression) Parameter Expression (required)- This parameter...

1 minute read.

VBA Option Explicit

VBA Option Explicit The Option Explicit in VBA is used to declare the variables at the top of your macro code. It is the most secure and easy option to maintain your variables....

5 minutes read.

VBA Regex Pattern Validation

VBA Regex Pattern Validation The key purpose of using Regex in VBA was to validate the data and extract the same category of data. There are certain formats that are standard...

6 minutes read.

Excel VBA FormatPercent Function

VBA FormatPercent Function: The FormatPercent function in VBA is used to apply a percent format to a numeric expression, and it returns the result as a string. Syntax FormatPercent (Expression, [NumDigitsAfterDecimal], [IncludeLeadingDigit], [UseParensForNegativeNumbers], [GroupDigits]) Parameter Expression (required)...

2 minutes read.

Excel VBA Tan Function

VBA Tan Function: The Tan function in VBA returns the tangent for the specified angle in radians. Syntax Tan (Number) Parameter Number (required) – This parameter represents the angle supplied in radiant that you want...

1 minute read.

Excel VBA StrConv Function

The StrConv function in VBA converts a string into a specified format. Syntax StrConv (String, Conversion, [LocaleID]) Parameter String (required) – This parameter represents the string to be converted. Conversion (required) – This parameter specifies the type of conversion. It can...

1 minute read.

Excel VBA: Do Until….Loop

DO UNTIL….Loop The “Do Until” Loop is same unlike DO WHILE statement just that it will keep on looping till the condition is not met. This loop is used to repeat a set...

4 minutes read.

Excel VBA Functions

What is a function? A function is also called a procedure, but it is not a sub procedure, it’s a function procedure. You have already been using some function in Excel,...

7 minutes read.