• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Excel Charts

          • Histogram Chart Excel
          • Basic Excel Formulas
          • Text to Columns in Excel
        • Excel Charts
        • Excel Tips

          • Excel Gantt Chart
          • IFERROR with VLOOKUP
          • Data Table in Excel
        • Excel Tips
        • Excel Tools in Excel

          • Stacked Column Chart
          • Cheat Sheet of Excel Formulas
          • Excel Data Validation
        • Histogram chart in excel
        • Others

          • Resources (A-Z)
          • Excel Functions
          • Financial Functions in Excel
          • Logical Functions in Excel
          • Lookup Reference Functions in Excel
          • Maths Function in Excel
          • TEXT and String Functions in Excel
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Excel Course 1
        • All in One Bundle

          All-in-One-Excel-VBA-Bundle
        • Excel course

          Excel-Training
        • Others

          • Excel advanced course
          • VBA Course
          • Excel Data Analysis Course
          • Excel for Marketing Course
          • Excel for Finance Course
          • View All
  • 120+ Courses All in One Bundle
  • Login

VBA StrConv

Home » Excel » Blog » VBA » VBA StrConv

VBA Strconv

VBA Strconv Function

VBA Strconv, where Strconv stands for “String Conversion”. We all know that in VBA if we want to use text then we have to use String function to define variables. With the help of Strconv function in VBA, we can change the text to Upper case, Lower case and Proper Case without selecting the cell where it may belong. The VBA Strconv cannot be used in Excel. But in excel we can change the text of Upper case, Lower case and Proper case with already defined commands.

Syntax of StrConv in Excel VBA

Start Your Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

The syntax for the VBA StrConv function in excel is as follows:

VBA StrConv Syntax

As per the syntax of StrConv;

  • String = Set of alphabets and text in any format.
  • Conversion = Type of conversion we want to apply to a selected string.

Different types of Conversions are mentioned below;

  • vbUpperCase (or 1) – This option converts any type of text to Upper.
  • vbLowerCase (or 2) – This option converts any type of text to Lower.
  • vbProperCase (or 2) – This option converts any type of text to Proper Case, which means the first letter of each word will be in Upper case and rest letters will be in Lower case.
  • vbUniCode (or 64) – This converts the text into Unicode.
  • vbFromUniCode (or 128) – This converts Unicode to Default system code which can be anything.

How to Use VBA StrConv in Excel?

We will learn how to use a VBA StrConv Function with few examples in excel.

You can download this VBA Strconv Excel Template here – VBA Strconv Excel Template

Example #1 – VBA StrConv

Step 1: Now open a new Module from Insert.

VBA Strconv Module

Step 2: To convert a text into different case formats we need to define 2 variables. Let’s consider our first variable Input1 as String as shown below.

Code:

Sub VBA_Strconv()

  Dim Input1 As String

End Sub

VBA Strconv example 1.1

Step 3: Now choose another variable and assign it as String. Here, our second variable is Output.

Code:

Sub VBA_Strconv()

  Dim Input1 As String
  Dim Output As String

End Sub

VBA Strconv example 1.2

Step 4: Now assign any text to defined variable Input1. Here we have considered a string of text “VBA string Conversion” which has the first word in Upper case, the second word in Lower case and third word in Proper case.

Popular Course in this category
VBA Training (3 Courses, 12+ Projects) 3 Online Courses | 13 Hands-on Projects | 45+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.7 (2,704 ratings)
Course Price

View Course

Related Courses
Excel Advanced Training (14 Courses, 21+ Projects)Excel Data Analysis Training (12 Courses, 6+ Projects)

Code:

Sub VBA_Strconv()

  Dim Input1 As String
  Dim Output As String

  Input1 = "VBA string Conversion"

End Sub

VBA Strconv example 1.3

Step 5: Now in variable Output we will put the values stored in Input1 with the help of StrConv function as shown below.

Code:

Sub VBA_Strconv()

  Dim Input1 As String
  Dim Output As String

  Input1 = "VBA string Conversion"
  Output = StrConv(

End Sub

VBA Strconv example 1.4

Step 6: Now under StrConv function assign Input1 variable and the type of case we want to convert. Let’s choose vbLowerCase first for lower case text as shown below.

Code:

Sub VBA_Strconv()

  Dim Input1 As String
  Dim Output As String

  Input1 = "VBA string Conversion"
  Output = StrConv(Input1, vbLowerCase)

End Sub

 example 1.5

Step 7: Now assign the message box to variable Output to see the result of function StrConv.

Code:

Sub VBA_Strconv()

  Dim Input1 As String
  Dim Output As String

  Input1 = "VBA string Conversion"
  Output = StrConv(Input1, vbLowerCase)

  MsgBox Output

End Sub

example 1.6

Step 8: Once done then compile the code and run it by clicking on the Play button located below the menu bar. We will get a message box with all the letters in Lower case as shown below.

VBA Strconv 1

Example #2 – VBA StrConv

In this example, we will see how vbUpperCase works for the same text which we have chosen in the above example. For this, we will continue using the same code, but we will change the conversion type only in StrConv function.

VBA Strconv example 2.1

Step 1: Now add conversion type in StrConv syntax as “vbUpperCase” as shown below.

Code:

Sub VBA_Strconv2()

  Dim Input1 As String
  Dim Output As String

  Input1 = "VBA String Conversion"

  Output = StrConv(Input1, vbUpperCase)

  MsgBox Output

End Sub

VBA Strconv example 2.1

Step 2: Again compile and run the code. We will see, conversion type vbUpperCase has converted the text stored in Input1 into upper cases as shown below.

VBA StrConv 2

Example #3 – VBA StrConv

In this example, we will see how vbProperCase works for the same text which we have seen in the above examples. Again,

Step 1: We will choose the same code which we have seen in examples.

Code:

Sub VBA_Strconv3()

   Dim Input1 As String
   Dim Output As String

   Input1 = "VBA String Conversion"

   Output = StrConv(Input1, vbProperCase)

   MsgBox Output

End Sub

VBA Strconv example 3.1

Step 2: Now add conversion type in StrConv syntax as “vbProperCase” as shown below.

Code:

Sub VBA_Strconv3()

    Dim Input1 As String
    Dim Output As String

    Input1 = "VBA String Conversion"

    Output = StrConv(Input1, vbProperCase)

   MsgBox Output

End Sub

Example 3.2

Step 3: Again compile and run the code. We will see, conversion type vbProperCase has converted the text stored in Input1 into upper cases as shown below which means the first letter of all the words will be in CAPS and rest of the letters will be small.

VBA Strconv 3

Example #4 – VBA StrConv

In this example, we will the conversion of a string with the help of vbFromUnicode. For this again we would need a module.

Step 1: Now open a new Module from the Insert menu list and start the subcategory of VBA Strconv as shown below.

Code:

Sub VBA_Strconv4()

End Sub

VBA Strconv Example 4.1

Step 2: In a similar way as we have seen in previous examples, we will again use same Variables Input1 and Output. Assign variable Input1 as Long.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long

End Sub

VBA Strconv Example 4.2

Step 3: And assign second variable Output as Byte. This is because we will store Unicode here.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long
Dim Output() As Byte

End Sub

Example 4.3

Step 4: Now in Output variable use Strconv function as shown below. And as per syntax, use any string. We are using the same text which we have seen above and select the conversion type as vbFromUnicode.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long
Dim Output() As Byte

Output = StrConv("VBA String Conversion", vbFromUnicode)

End Sub

Example 4.4

Step 5: Open a For-Next loop as shown below.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long
Dim Output() As Byte

Output = StrConv("VBA String Conversion", vbFromUnicode)
For

Next

End Sub

Example 4.5

Step 6: In For loop, give value from 0 to UBound for Output variable under Input1.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long
Dim Output() As Byte

Output = StrConv("VBA String Conversion", vbFromUnicode)

For Input1 = 0 To UBound(Output)

Next

End Sub

VBA Strconv Example 4.6

Step 7: At last, to print the values stored in Input1 through for loop we will use Debug.Print as shown below.

Code:

Sub VBA_Strconv4()

Dim Input1 As Long
Dim Output() As Byte

Output = StrConv("VBA String Conversion", vbFromUnicode)

For Input1 = 0 To UBound(Output)
Debug.Print Output(Input1)

Next

End Sub

Example 4.7

Step 8: Now run the code. We will see, in the immediate window, the sequence of Unicode will appear randomly.

VBA Strconv

Pros of VBA Strconv

  • Long set of data can easily be formatted with proper fonts with VBA Strconv.
  • For maintaining a database where we need to keep proper fonts which are mostly used, we can choose VBA Strconv to convert fonts in any format.

Things to Remember

  • It can only be used for texts.
  • This process is similar to the insert function of Excel where we can use Upper, Lower and Proper function to convert the fonts.
  • It can be automated by recording a macro. That will give the same results as VBA Strconv.
  • Save the file in Macro Enable Excel, so that you would be able to see and edit the code in the future.
  • We can use String or Long to define variables. Both can be used for text.

Recommended Articles

This is a guide to VBA StrConv. Here we discuss how to use Excel VBA StrConv Function along with practical examples and downloadable excel template. You can also go through our other suggested articles –

  1. Copy Paste Function in VBA
  2. Substring Excel Function
  3. VBA Subscript out of Range
  4. Excel ISNUMBER Formula

All in One Excel VBA Bundle (120+ Courses, 30+ Projects)

120+ Online Courses

30+ Projects

500+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar
Excel Functions Tutorials
  • VBA
    • VBA Max
    • VBA Environ
    • VBA Not
    • VBA LOOKUP
    • Programming in Excel
    • VBA Name Worksheet
    • VBA ScreenUpdating
    • VBA Do Loop
    • VBA Declare Array
    • VBA Macros
    • VBA Delete Sheet
    • VBA Editor
    • VBA Error Handling
    • VBA Goal Seek
    • VBA DateDiff
    • VBA On Error Resume Next
    • VBA Examples
    • VBA Counter
    • VBA Val
    • VBA Me
    • VBA Double
    • VBA Variable Types
    • VBA FreeFile
    • VBA Switch Case
    • VBA Unprotect Sheet
    • VBA Format Number
    • VBA ReDim
    • VBA IF Statements
    • VBA DoEvents
    • VBA Public Variable
    • VBA Columns
    • VBA Cdate
    • VBA Selection Range
    • VBA Hide Columns
    • VBA COUNTA
    • VBA Insert Row
    • VBA Protect Sheet
    • VBA AutoFill
    • VBA IF Not
    • VBA GetObject
    • VBA Debug Print
    • VBA Collection
    • VBA Text
    • VBA Randomize
    • VBA Variant
    • VBA Selection
    • VBA Right
    • VBA Date Format
    • VBA Rename Sheet
    • VBA Paste Values
    • VBA InputBox
    • VBA Conditional Formatting
    • VBA Pause
    • VBA Pivot Table
    • VBA Message Box
    • VBA OFFSET
    • VBA ByRef
    • FileCopy in VBA
    • VBA StrConv
    • VBA SUB
    • VBA Boolean
    • VBA Global Variables
    • VBA Worksheets
    • VBA IIF
    • VBA Close UserForm
    • VBA Variable Declaration
    • VBA Join
    • VBA Dictionary
    • VBA Operators
    • VBA Charts
    • VBA For Each Loop
    • VBA FileDialog
    • VBA Format
    • VBA MID
    • VBA GetOpenFileName
    • VBA DatePart
    • VBA Code
    • VBA Option Explicit
    • VBA FileSystemObject (FSO)
    • VBA ASC
    • VBA UserForm
    • VBA Cells
    • VBA InStrRev
    • VBA Class Module
    • VBA Constants
    • VBA Length of String
    • VBA DateSerial
    • VBA StrComp
    • VBA Array Length
    • VBA Check File Exists
    • VBA Ubound
    • VBA CDBL
    • VBA Activate Sheet
    • VBA DateValue
    • VBA Borders
    • VBA Comment
    • VBA Intersect
    • VBA Workbook
    • VBA Concatenate
    • VBA Name
    • VBA Find and Replace
    • VBA Tutorial
    • VBA CSTR
    • VBA Save As
    • VBA Hyperlink
    • VBA Print
    • VBA Switch
    • VBA END
    • VBA Like
    • VBA Set
    • VBA excel programming
    • VBA Call Sub
    • VBA Object
    • VBA RoundUp
    • VBA ArrayList
    • VBA Named Range
    • VBA PowerPoint
    • VBA Block Comment
    • VBA OverFlow Error
    • VBA Insert Column
    • VBA Lcase
    • VBA List Box
    • VBA Delete File
    • VBA Clear Contents
    • VBA TextBox
    • VBA Font Color
    • VBA Range Cells
    • VBA INT
    • VBA UCASE
    • VBA Value
    • VBA Remove Duplicates
    • VBA Break for Loop
    • VBA Sleep
    • VBA Do Until Loop
    • VBA Union
    • VBA Long
    • VBA Copy Paste
    • VBA Data Types
    • VBA Delete Column
    • VBA Enum
    • VBA IsEmpty
    • VBA 1004 Error
    • VBA RegEx
    • VBA IsNumeric
    • VBA Paste
    • VBA Transpose
    • VBA Left
    • VBA Delete Row
    • VBA Integer
    • VBA Active Cell
    • VBA InStr
    • VBA Round
    • VBA Subscript out of Range
    • VBA Dim
    • VBA Replace
    • VBA Sort
    • VBA String
    • VBA Split
    • VBA Wait
    • VBA MOD
    • VBA Time
    • VBA TIMER
    • VBA While Loop
    • VBA Date
    • Excel VBA MsgBox
    • VBA IFError
    • VBA Color Index
    • VBA Match
    • VBA Case
    • VBA Arrays
    • VBA GoTo
    • VBA On Error
    • VBA Range
    • VBA Do While Loop
    • VBA Number Format
    • VBA Loops
    • VBA TRIM
    • VBA Find
    • VBA Select Case
    • VBA Else If
  • Excel Functions (10+)
  • Excel Tools (97+)
  • Financial Functions in Excel (17+)
  • Logical Functions in Excel (12+)
  • Lookup Reference Functions in Excel (30+)
  • Maths Function in Excel (39+)
  • TEXT and String Functions in Excel (25+)
  • Date and Time Function in Excel (20+)
  • Statistical Functions in Excel (55+)
  • Information Functions in Excel (4+)
  • Excel Charts (44+)
  • Excel Tips (195+)
  • Workplace Productivity (4+)
  • Microsoft Office Tools (14+)
  • Excel Formula and Functions (20+)
  • MS Excel Shortcuts (4+)
Excel Functions Courses
  • VBA Training
  • Excel Advanced Training
  • Excel Data Analysis Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Online Excel Course
  • Free Vba Course
Certification Courses
  • All Courses
  • Excel VBA Course - All in One Bundle
  • VBA Course
  • Excel Data Analysis Course
  • Excel for Marketing Course
  • Excel for Finance Course
  • Excel for HR Training
Resources
  • Resources (A To Z)
  • Excel Charts
  • Excel Tips
  • Excel Tools in Excel
  • Excel Functions
  • Financial Functions in Excel
  • Logical Functions in Excel
  • Lookup Reference Functions in Excel
  • Maths Function in Excel
  • TEXT and String Functions in Excel
  • Date and Time Function in Excel
  • Statistical Functions in Excel
  • Information Functions in Excel
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

Download VBA Strconv Excel Template

By continuing above step, you agree to our Terms of Use and Privacy Policy.
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect

Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More

Limited Period Offer - Limited Period Offer - All in One Excel VBA Bundle (120+ Courses, 500+ hours of Videos) View More