×

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

Excel VBA StrComp Function

VBA StrComp Function: The StrComp function in VBA compares two strings and returns an integer value displaying the result of the comparison. Syntax StrComp (String1, String2, [Compare]) Parameter String1 (required)- This parameter represents the first string to...

2 minutes read.

Excel VBA FormatDateTime Function

VBA FormatDateTime Function: The FormatDateTime function in VBA returns the result as a string after applying a date and/or time format to the supplied expression. Syntax FormatDateTime (Expression, [NamedFormat]) Parameter Expression (specified) – This parameter...

2 minutes read.

VBA Global Variable

What is Global Variable? The Global Variables in VBA refers to the variables declared before the start of any macro. They are defined outside the functions and are used by all the functions or...

6 minutes read.

Excel VBA Array

Introduction to VBA Array An array is a type of variable that holds more than one piece of data. In VBA, you can refer to a specific variable (element) of an array by using...

5 minutes read.

Excel VBA CBool Function

VBA CBool Function: The CBool function in VBA calculates an expression and returns the result as a Boolean data type. Syntax CBool (Expression) Parameter Expression (required) – This parameter represents the expression that that you want...

1 minute read.

Excel VBA InStr Function

VBA InStr Function The InStr function in VBA searches for a substring inside the given string. It returns the position of a substring within a string, as an integer if the substring is found...

1 minute read.

Excel VBA Sin Function

VBA Sin Function: The Sin function in VBA returns the sine value for a supplied angle. Syntax Sin (Number) Parameter Number (required) –This parameter represents the angle (in radians) to calculate the sine value. Return This function...

1 minute 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.

Miscellaneous Exercise of conditional statements and Loop

We have the already worked with syntax and examples of conditional statements and loops in the previous tutorials. In this tutorial, we will learn how to work with both together.  We will explain...

3 minutes read.

Excel VBA Timer Function

Excel VBA Timer Function: The Timer function in VBA returns a Single data type, evaluating the number of seconds that have elapsed since midnight of the current day. Syntax Timer () Parameter NA Return This...

1 minute read.

Excel VBA CSng Function

VBA CSng Function: The CSng function in VBA converts the supplied expression into a single-precision floating-point number (single data type). Syntax CSng (Expression) Parameter Expression (required) – This parameter represents the expression that you want...

1 minute read.

CodeIgniter File Uploading Class

The Codeigniter provides a file Uploading library class which is used to upload any file such as images, pdf, mp3, etc. to the codeigniter’s application. It also allows to set various preferences such...

5 minutes read.

Four VBA Clear methods

Four VBA Clear methods In Microsoft Excel, many times, a situation arises where the user wants to clear the data or any specific range of data. What if the user automates this task with...

6 minutes read.

VBA UBound

VBA UBound  The UBound or Upper Bound function in VBA is used to specify the length of an array and returns the highest subscript for a dimension for the specified array. It is...

3 minutes read.

Userform Events

What are Events? Anything you do in to trigger an excel file is an event (an action). Example: If you want a greeting message ‘Good Day’ whenever an excel file is...

7 minutes read.

Excel VBA Year Function

Excel VBA Year Function: The Year function in VBA returns the four-digit year for the specified date. Syntax Year (Date) Parameter Date (required) – This parameter represents the significant date. Return This function returns the four-digit year...

1 minute read.

VBA Charts Basic Operations

VBA Charts- Basic Operations The Chart Object in Excel VBA represents the collection of all the charts sheet present in a workbook. A chart can be either an embedded chart or a separate chart sheet. The...

6 minutes read.

Excel VBA String Function

The String function in VBA creates a String, consisting of several repeated characters. Syntax String (Number, Character) Parameter Number (required) – This parameter represents the number of characters in the returned String. Character (required) – This parameter...

1 minute 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.

Excel VBA DateAdd Function

The DateAdd function in VBA adds a time interval to a supplied date and/or time and returns the resultant date/time. Syntax Dateadd (Interval, Number, Date) Parameter Interval (required) – This parameter a string specifying the interval to be...

1 minute read.