WallStreetMojo

WallStreetMojo

WallStreetMojo

MENUMENU
  • Free Tutorials
  • Certification Courses
  • Excel VBA All in One Bundle
  • Login
Home » Excel, VBA & Power BI » Learn VBA » VBA LCase

VBA LCase

Excel VBA LCase Function

LCase is an inbuilt function in vba which is used to convert an input string provided to it in the lowercase, it takes a single argument which is the string as an input and the output generated by this function is a string, the one thing to keep in mind is that this function converts all the function to lowercase, not just any single character.

You must have tried the same formula (LOWER) as excel in VBA, and you have not found it. Because in VBA, the lowercase is named slightly different. In VBA, it is in shortcut name, i.e., “LCASE.” Here “L” stands for “LOWER,” so the formula reads “LOWERCASE.”

VBA-LCase

Syntax

vba lowercase

  • String: is nothing but the text value we are trying to convert to Lower Case. We can supply the text directly to the formula, it can be a cell reference, and it can be through variable as well.

How to Convert Text in Lowercase in VBA?

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

Example #1

Let’s try to convert the text value “Hello Good Morning” to the lower case by using the LCASE function.

Step 1: Start the subprocedure by naming the excel macro.

Code:

Sub LCase_Example1()

End Sub

excel vba Lcase example 1.1

Step 2: Declare the variable k as String.

Code:

Sub LCase_Example1()

Dim k As String

End Sub

Lcase example 1.2

Step 3: Assign the value to the variable “k” by applying the “LCASE” function.

Lcase example 1.3

Step 4: Here, the string is our desired text value that we are trying to convert to lower case, and the desired string value is “Hello Good Morning.”

Code:

Sub LCase_Example1()

Dim k As String

k = LCase("Hello Good Morning")

End Sub

Lcase example 1.4

Step 5: Now show the result of the variable “k” in the message box.

Code:

Sub LCase_Example1()

Dim k As String

k = LCase("Hello Good Morning")

MsgBox k

End Sub

excel vba lcase example 1.5

Ok, coding is done. Let’s run the code to see the result.

Popular Course in this category
Sale
VBA Training (3 Courses, 12+ Projects)
4.6 (247 ratings)
3 Courses | 12 Hands-on Projects | 43+ Hours | Full Lifetime Access | Certificate of Completion
View Course

excel vba lcase example 1.6

So LCase converted the text value “Hello Good Morning” to “hello good morning” with the simple coding technique.

Example #2

We have seen how the LCASE function works in VBA. In the above example, we have directly supplied the value to the formula itself. Now we will see how we can use cell reference value to the formula.

Assume you have the word “Hello Good Morning” in the cell A1 like the below image.

Lcase example 2.1

Step 1: We will convert the cell A1 value to the lower case by showing the result in Range B1 cell, so the code will be Range (“B1”).Value =

Code:

Sub LCase_Example2()

Range("B1").Value

End Sub

excel vba lcase example 2.2

Step 2: In cell B1 through the LCASE function, we will store the result, so open the function.

excel vba lcase example 2.3

Step 3: In this example, the VBA string value is a cell reference, not a direct value. So give the cell reference as Range (“A1”).Value.

Code:

Sub LCase_Example2()

Range("B1").Value = LCase(Range("A1").Value)

End Sub

example 2.4

So, ok, we are done with the VBA coding part. Run the code and see the magic in the B1 cell.

example 2.5

Example #3

Converting a single cell value or a single direct value isn’t the biggest challenge. When we need to deal with the “n” number of values in the worksheet, then we need to apply loops to loop through all the cells and convert them to lower case values.

Assume below is the data you have in an excel worksheet.

example 3.1

If you are not aware of loops, then you need to go back to the basics of VBA coding. Refer our articles on “VBA Loops” to have a fair bit of knowledge on loops. The below code will convert the above names to the lower case.

Code:

Sub LCase_Example3()

Dim k As Long

For k = 2 To 8
Cells(k, 2).Value = LCase(Cells(k, 1).Value)
Next k

End Sub

example 3.2

This will convert all the text values from row 2 to row 8 in the lowercase function.

example 3.3

Based on your cells, you can increase the limit of the loop from 8 to whatever the last row number of your data.

Recommended Articles

This has been a guide to VBA LCase. Here we discussed how to use the Excel VBA LCase function to convert the text into lowercase with the help of practical examples and a downloadable excel template. Below are some useful articles related to VBA –

  • Count Function in Excel VBA
  • CDBL Function in VBA
  • Union in Excel VBA
  • VBA UCase Function
0 Shares
Share
Tweet
Share
VBA Training (3 Courses, 12+ Projects)
  • 3 Courses
  • 12 Hands-on Projects
  • 43+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>
Primary Sidebar
Footer
COMPANY
About
Reviews
Contact
Privacy
Terms of Service
RESOURCES
Blog
Free Courses
Free Tutorials
Investment Banking Tutorials
Financial Modeling Tutorials
Excel Tutorials
Accounting Tutorials
Financial Statement Analysis
COURSES
All Courses
Financial Analyst All in One Course
Investment Banking Course
Financial Modeling Course
Private Equity Course
Venture Capital Course
Excel All in One Course

Copyright © 2021. CFA Institute Does Not Endorse, Promote, Or Warrant The Accuracy Or Quality Of WallStreetMojo. CFA® And Chartered Financial Analyst® Are Registered Trademarks Owned By CFA Institute.
Return to top

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

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

Book Your One Instructor : One Learner Free Class
Let’s Get Started
Please select the batch
Saturday - Sunday 9 am IST to 5 pm IST
Saturday - Sunday 9 am IST to 5 pm IST

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

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

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

Login

Forgot Password?

WallStreetMojo

Download VBA LCase Excel Template

New Year Offer - VBA Training Course (6 courses, 35+ hours video) View More