Just like the LOWER function, there is a similar inbuilt function in Excel VBA – LCASE The VBA LCASE function takes a string as the input and converts it into a lower case string.
Syntax of VBA LCASE Function
Below is the syntax of the VBA LCase function ‘String’ is the text that you want to convert to lower case. You can use a text string, a range reference that contains the text string, or a variable that has the text string. Let’s have a look at a couple of example of using the LCase function.
VBA LCase Examples
The below code would convert the specified text into lower case and show it in a message box.
Here is another example, where we have used a variable (‘Var’) to hold the text string and then used the LCase function to convert it into lower case. Another example below shows how to take the string from a cell (A1) and show the lowercase version of it in a message box. While all these above examples work, you’re unlikely to use this function to simply convert or show the lowercase string. Below is a more practical example of the LCase function in Excel VBA. The below code would go through all the cells in the selected range and convert all the text strings into lower case.
A few important things to know about the VBA LCase function: Other Useful VBA Functions:
VBA UCase Function. VBA TRIM Function. VBA INSTR Function. VBA SPLIT FUNCTION.
Sub LCaseExample1() Dim W as Worksheet: set W = ActiveSheet Dim R As Range Set R = Selection Dim cell as Range For Each cell In Selection Cell.Value = LCase(Cell) Next cell End Sub This code is wrong. What about Dim for Cell?