In Excel VBA, use the built-in LCase function to convert text to lowercase; its string-returning counterpart, LCase$, is also available. For example, result = LCase$(sourceText) changes uppercase letters in a string to lowercase. In a normal Excel worksheet formula, use LOWER instead: VBA’s LCase is not a worksheet function you can enter directly in a cell.
What VBA’s LCase function does
LCase takes a string expression and returns that text with uppercase letters converted to lowercase. Characters that have no uppercase/lowercase distinction—such as digits, spaces, punctuation, and most symbols—remain unchanged. It does not remove spaces, correct spelling, or change the underlying meaning of the text.
For instance, passing North AMERICA 42! to LCase returns north america 42!. The source string is not altered in place: VBA returns a new string, which your code can assign to a variable, a cell, or a function result. This makes the function useful for normalizing text before comparing it, preparing labels, or cleaning values for later processing.
The function name is written as LCase, with a lowercase L followed by “Case.” VBA does not distinguish uppercase and lowercase in function names, so lcase and LCase refer to the same built-in function. The dollar-sign form, LCase$, is a separate spelling provided for code that expects a String result.
Syntax and a basic VBA example
The syntax is LCase(string) or LCase$(string), where string is the text expression to convert. Assign the returned value if you want to keep it. This example puts the converted text in a new variable rather than changing the original variable:
Sub ShowLowercaseExample()
Dim sourceText As String
Dim lowerText As String
sourceText = "Quarterly SALES Report"
lowerText = LCase$(sourceText)
MsgBox lowerText
End Sub
When run, the message box displays quarterly sales report. The original sourceText still contains its original capitalization. In production code, you might assign the result to a worksheet cell or use it in a comparison rather than display it.
Using LCase is appropriate when the result can be treated as a Variant, while LCase$ explicitly returns a String. For ordinary text processing, either form is suitable. The dollar form can make the intended return type clearer, but it does not make the conversion more comprehensive or change which characters are converted.
Convert cell text with a macro
A macro can convert text values directly in a selected range. The example below changes only cells containing text constants: it skips formulas, numbers, blanks, and error values. Select the cells you intend to process, then run the macro. It is intended for ordinary, unlocked cells; test it on a copy first, especially if the selection includes merged cells or important data.
Sub LowercaseSelectedTextValues()
Dim cell As Range
' Change text constants only; leave formulas and other values alone.
If TypeName(Selection) <> "Range" Then Exit Sub
For Each cell In Selection.Cells
If Not cell.HasFormula Then
If Not IsError(cell.Value2) Then
If VarType(cell.Value2) = vbString Then
cell.Value2 = LCase$(CStr(cell.Value2))
End If
End If
End If
Next cell
End Sub
To add it in Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor, choose Insert > Module, and paste the code into the module. If the Developer tab is visible, you can also choose Developer > Visual Basic. On a Mac, use Developer > Visual Basic or try Option+F11; depending on the keyboard, you may need to hold Fn as well. Save a macro-containing workbook as an Excel Macro-Enabled Workbook (.xlsm).
Save a separate copy of the workbook before running a macro that changes cell contents. Macro changes cannot be undone with Ctrl+Z in Excel, and running this procedure replaces the selected text values with lowercase versions. If a worksheet is protected or a cell cannot be edited, the macro may stop with an error, so check the sheet and selection first.
Use lowercase as a worksheet formula instead
If you only need a calculated lowercase result in a cell, a VBA macro is usually unnecessary. Excel’s worksheet function is LOWER, which returns a lowercase version of a text value and leaves the original cell untouched.
With the source text in cell A2, enter this formula in B2:
=LOWER(A2)
If A2 contains Blue Sky, B2 displays blue sky. Fill the formula down to process more rows. To replace the original entries with the results, copy the formula cells and use Home > Paste > Paste Values over the source cells, taking care not to overwrite data you still need. This separates the conversion step from the decision to replace the original values.
A worksheet formula recalculates when its referenced input changes, while a macro that writes lowercase text into a cell makes a one-time change to that cell’s value. Choose based on the desired behavior: use LOWER for a live result alongside the source, and use VBA when you need to automate a repeatable editing task or incorporate the conversion into a larger procedure.
Create a reusable VBA worksheet function
You can also make a small custom VBA function, often called a user-defined function (UDF), and call it from a worksheet formula. Insert this code into a standard module in the Visual Basic Editor:
Function LowercaseText(ByVal inputText As String) As String
' Return the supplied text in lowercase.
LowercaseText = LCase$(inputText)
End Function
With the source text in A2, enter =LowercaseText(A2) in another cell. If A2 contains New Product, the result is new product. The UDF is useful if you want a recognizable custom function name or plan to add related text-processing logic. For simple lowercase conversion, Excel’s built-in LOWER function is easier to share because it does not depend on VBA being enabled.
Custom functions must be saved in the workbook or an add-in where the formula can find them. Save a workbook containing VBA as .xlsm (or use an appropriate add-in format). A recipient who opens the file with macros disabled may not be able to calculate a VBA-based UDF; a cell using it can show a #NAME? error. Excel for the web can open macro-enabled workbooks, but it cannot create, run, or edit VBA macros, so use desktop Excel to work with this code.
LCase, LOWER, and StrConv compared
These options all relate to changing letter case, but they are intended for different places in Excel:
LCaseandLCase$are VBA functions. Use them in VBA procedures and custom functions.LOWERis an Excel worksheet function. Enter it in a cell when you want a formula result.StrConvis another VBA function that can convert text using a conversion argument such asvbLowerCase. It is handy if a procedure already usesStrConvfor other case conversions, butLCaseis the more direct choice for lowercase text.
For example, a VBA assignment can use lowerText = StrConv(sourceText, vbLowerCase). In this statement, sourceText and lowerText need to be declared variables, and vbLowerCase is a built-in VBA constant. Do not confuse this with a worksheet formula: StrConv is not entered directly into a cell as an Excel function.
Another common misunderstanding is that lowercase conversion makes a comparison case-insensitive. It can help: converting both strings to lowercase before comparing gives a normalized comparison for many ordinary text uses. But VBA also has comparison settings, and some text rules depend on locale. For a straightforward VBA text comparison, you can set Option Compare Text at the top of a module; this affects string comparisons in that module. Alternatively, use an explicit comparison method when the exact comparison behavior matters. Avoid changing case just to compare if preserving the original strings is important.
Common issues and safer handling
Several practical details can affect a lowercase routine. Check these before running code over a large or important range:
- Formulas versus values: A macro that writes to a formula cell replaces its formula. The sample macro deliberately skips formula cells, while
LOWERcan transform a formula’s result without replacing the source formula. - Errors and non-text data: A cell containing an Excel error is not an ordinary string. The sample checks for errors and processes only text constants, rather than coercing every number or date into text.
- Undo: VBA changes are not reversed by Excel’s normal Undo command. Save a copy and verify the selected range before running a write-enabled macro.
- Protected sheets: A macro may be unable to write to locked cells on a protected worksheet. Confirm permissions or work on an authorized, unprotected copy.
- Macro availability: A macro-enabled file may open with its VBA disabled, depending on security settings. Run code only from workbooks and sources you trust; do not lower security settings just to run an unknown macro.
If a macro seems to do nothing, confirm that the intended cells are selected and that they contain text constants rather than formulas or numbers. If a worksheet UDF shows #NAME?, confirm that the function is in a standard module, the workbook was saved with VBA, and macros are available. If only a few records need conversion, a helper column with LOWER can be simpler and easier to inspect than a macro.
Character handling and what lowercase does not do
Lowercase conversion changes letter case; it does not standardize every possible text difference. For example, LCase does not trim leading or trailing spaces, remove accents, collapse repeated spaces, or strip punctuation. If those are separate requirements, handle them explicitly rather than expecting a case function to clean the whole value.
Case conversion for accented and other non-English characters can depend on the language and locale behavior available to the system. If a workbook processes names or text in multiple languages, check the expected results with representative data on the computers where it will run. Do not assume that lowercasing is a universal method for identifying two strings as equivalent: Unicode characters can have language-specific casing rules, and visually similar characters are not necessarily identical.
It is also worth preserving the original text when it is needed for display, audit trails, or later review. A formula in a neighboring column gives you both the source and a converted result. A macro that overwrites values is more convenient for a final cleanup, but it removes the source capitalization unless you keep a backup.
Frequently Asked Questions
What is the VBA function for lowercase?
Use LCase or LCase$. For example, assign LCase$(sourceText) to a String variable to get a lowercase result.
Can I type LCase directly into an Excel cell?
No. LCase is a VBA function, not a built-in worksheet function. Use LOWER in a cell, or create a VBA UDF and call that function from the worksheet.
What is the difference between LCase and LCase$?
Both convert uppercase letters to lowercase. LCase returns a Variant, while LCase$ returns a String. The dollar-sign version is often convenient when the code expects a String.
How do I lowercase a whole column without changing its formulas?
Use a helper column with LOWER and fill the formula down, or use a macro designed to skip formula cells. Check the results before replacing any source data.
Can Excel for the web run a VBA lowercase macro?
No. Excel for the web does not run VBA macros. Open the workbook in desktop Excel for Windows or Mac to run or edit VBA; worksheet formulas such as LOWER are the simpler option when a macro is not required.
Related
- Excel Text to Columns: Split at the First Delimiter
- Excel Text to Columns: Use a Line Break Delimiter
- Excel Text to Columns: Split at the Last Space
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Outlook Macros: How to Enable Them Safely in Classic OutlookTo enable VBA macros in classic Outlook for Windows, open File > Options > Trust Center > Trust…
- Excel VBA: Save a Sheet as a Web Page with FormattingYes. In desktop Excel for Microsoft 365 on Windows, VBA can publish one worksheet as a static HTML…
- Excel VBA: Get a Value From a UserForm TextBoxIn Excel VBA, read a UserForm TextBox with its Value property: for example, userName = Me.txtName.Value inside the…
- VBA Error Handling for Multiple Errors in One MacroVBA handles runtime errors one at a time: use On Error GoTo to route an unexpected failure to…
- Excel VBA Text Color: Change Font and Cell Colors EasilyTo change text color in Excel VBA, set a range’s Font.Color property, usually with RGB(red, green, blue). For…
- Excel VBA Find LookIn: What It Means and How to Use ItIn Excel VBA, LookIn is an argument of the Range.Find method that tells Excel what kind of content…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.