EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 120+ Courses All in One Bundle
  • Login
Home VBA VBA Resources VBA String and Text Functions VBA LCase
Secondary Sidebar
VBA String and Text Functions
  • VBA String and Text
    • VBA Constants
    • VBA TRIM
    • VBA Find
    • VBA Case
    • VBA Replace
    • VBA String
    • VBA Split
    • VBA InStr
    • VBA RegEx
    • VBA Left
    • VBA UCASE
    • VBA LCase
    • VBA Concatenate
    • VBA StrComp
    • VBA StrConv
    • VBA Find and Replace
    • VBA Right
    • VBA ASC
    • VBA InStrRev
    • VBA Length of String
    • VBA Format
    • VBA MID
    • VBA Concatenate Strings
    • VBA SubString
    • VBA String Comparison
    • VBA String Array
    • VBA Dynamic Array
    • VBA Replace String

VBA LCase

By Madhuri ThakurMadhuri Thakur

VBA LCase

Excel VBA LCase Function

In this article, we will discuss changing the text value to lower case. We can do this by the LCase function in VBA. Similar to the UCase, LCase changes the upper case characters to lower case characters in VBA. The syntax will be as follows to use the Lcase function in VBA:

Syntax of LCase in Excel VBA

The syntax for the LCase function excel VBA is as follows:

VBA LCase

The string is the input we provide to the function. The input can be a single cell or a group of cells, or a whole cell range. If we use Lcase, it only changes the text into the lower case, but it does not change the structure of the text. For example, if we have a semicolon or a comma in our text, it remains untouched. For example, if we input Lcase ( EVERYTHING ), the result we will have is everything. Secondly, in an example, if we have an input such as Lcase (ANAND, ARAN / NEERAJ ), the result will be as follows: Anand, aran / Neeraj.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Let us use this function in a few examples, which will provide a better thought process about the function.

All in One Financial Analyst Bundle(250+ Courses, 40+ Projects)
Financial ModelingInvestment BankingUS GAAPCFA-Level 1 & 2
Equity ResearchM & A ModelingPrivate Equity ModelingForex Trading
Price
View Courses
250+ Online Courses | 40+ Projects | 1000+ Hours | Verifiable Certificates | Lifetime Access
4.9 (86,389 ratings)
Note: Keep in mind to enable the developer’s tab from the files tab and then from the options section to use VBA in excel.

How to Use Excel VBA LCase Function?

We will learn how to use a VBA LCase with few examples in Excel.

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

VBA LCase Function – Example #1

I have a string inside cell A1 of sheet 1. The string is in the upper case; we will convert it to lower case by Lcase function. Have a look at the string below.

VBA Example

Follow the below steps to use LCase in Excel VBA.

Step 1: We start by going to the developer’s tab to open VB Editor from a Visual Basic Option.

VBA LCase Example 1

Step 2: Now click on the Insert tab, which will show us to insert a module in the VBA. To start writing the code, double-click on the module.

Module VBA LCase Function

Step 3: Then declare a macro Sub Function.

Code:

Sub Sample()

End Sub

Sub Sample module of VBA

Step 4: To use any of the sheet properties, we need to activate the sheet first.

Code:

Sub Sample()

Worksheets("Sheet1").Activate

End Sub

Activate WorkSheet

Step 5: Now, let us change the value in cell A1 by using the LCase Function as follows.

Code:

Sub Sample()

Worksheets("Sheet1").Activate
Range("A1").Value = LCase(Range("A1"))

End Sub

Range oF Worksheet

Step 6: When we run the above code, we get the following result.

VBA LCase 1

In the above example, we have changed the text from upper case to lower case using Lcase function.

VBA LCase Function – Example #2

Let us take input from the user in the Upper case and change the value of text to lower case using the Lcase function.

Step 1: Again, we start by going in VB Editor from Visual Basic under the developer’s tab.

VBA LCase 2

Step 2: Click on the Insert tab and add a new module.

Module VBA LCase 2

Step 3: Declare a second macro different from the first one as two macros cannot have the same name.

Code:

Sub Sample1()

End Sub

Sub Sample 1

Step 4: Use Dim to declare two variables, A and B, as String.

Code:

Sub Sample1()

Dim A, B As String

End Sub

Dim A as string

Step 5: Use the Inputbox function to take input from the user and store the value in variable A.

Code:

Sub Sample1()

Dim A, B As String
A = InputBox("Write a string", "In Uppercase")

End Sub

Input String

Step 6: In the B store, the value of the Input string is changed from upper case to lower case using Lcase function.

Code:

Sub Sample1()

Dim A, B As String
A = InputBox("Write a string", "In Uppercase")
B = LCase(A)

End Sub

Lower Case

Step 7: Use the Msgbox Function to display the result.

Code:

Sub Sample1()

Dim A, B As String
A = InputBox("Write a string", "In Uppercase")
B = LCase(A)
MsgBox B

End Sub

MsgBox

Step 8: Run the above code by pressing F5, and we get a prompt to give a value. Input any string. Click on OK to see the result.

VBA LCase 2

VBA LCase Function – Example #3

Above, we have discussed how this Lcase function does not affect the structure of the string, i.e. if there is a comma or a semicolon or any other special character, it remains unaffected. For demonstration, I have a string in cell C1 with some special characters in it. It is as below,

Step 1: Again, we start by going in VB Editor from Visual Basic under the developer’s tab.

VBA LCase 3

Step 2: Click on Insert and add module above to let us write the code in the same module.

MODULE

Step 3: Declare a third macro name using the Sub Function.

Code:

Sub Sample2()

End Sub

VBA LCase Example 3

Step 4: In order to use the string in cell C1, we need to activate the sheet 1 first.

Code:

Sub Sample2()

Worksheets("Sheet1").Activate

End Sub

Sheet 1

Step 5: Now, let us use the LCase function on cell C1 to check whether it affects the special characters or not.

Code:

Sub Sample2()

Worksheets("Sheet1").Activate
Range("c1").Value = LCase(Range("c1"))

End Sub

LCase Range

Step 6: Execute the above code by using the run button and see the following result.

VBA LCase 3

We can see that Lcase does not affect any of the special characters in the string.

VBA LCase Function – Example #4

Now in this example, let us change a range of data from upper case to lower case using the LCase function. For demonstration, my data is in Sheet 2, which is as follows,

VBA LCase Example 4

I want to change the strings in column A which are in upper case, to lower case in column B.

Step 1: Click on the Insert Tab and add Module

Module VBA LCase 4

Step 2: Declare a macro name for this example.

Code:

Sub Sample3()

End Sub

VBA LCase Example 4.1

Step 3: Activate sheet 2 first so that we can use its properties.

Code:

Sub Sample3()

Worksheets("Sheet2").Activate

End Sub

VBA LCase Example 4.2

Step 4: Declare a variable A and its data type as long.

Code:

Sub Sample3()

Worksheets("Sheet2").Activate
Dim A As Long

End Sub

vba value Example 4.3

Step 5: Now, we will use for loop to loop the next data in the next row.

Code:

Sub Sample3()

Worksheets("Sheet2").Activate
Dim A As Long
For A = 2 To 6

End Sub

vba LCase Example 4.4

Step 6: Let us change the value in column A to lower case and store it in column B by the following code.

Code:

Sub Sample3()

Worksheets("Sheet2").Activate
Dim A As Long
For A = 2 To 6
Cells(A, 2).Value = LCase(Cells(A, 1).Value)

End Sub

VBA LCase Example 4.5

Step 7: Loop until the last row is found,

Code:

Sub Sample3()

Worksheets("Sheet2").Activate
Dim A As Long
For A = 2 To 6
Cells(A, 2).Value = LCase(Cells(A, 1).Value)
Next A

End Sub

VBA LCase Example 4.6

Step 8: When we run the above code, we get the following result.

VBA LCase 4

Things to Remember

  • Lcase changes text to lower case.
  • The input we provide to the function can be a single cell or a range of cells.
  • If the input function has any special symbols or characters, it remains unchanged.

Recommended Articles

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

  1. VBA InStr
  2. VBA Integer
  3. VBA Select Cell
  4. VBA Transpose
Popular Course in this category
VBA Training (4 Courses, 12+ Projects)
  4 Online Courses |  13 Hands-on Projects |  50+ Hours |  Verifiable Certificate of Completion
4.7
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign In
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Excel Charts
  • Excel Tips
  • All Tutorials
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

ISO 10004:2018 & ISO 9001:2015 Certified

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

EDUCBA
Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more