I need you to write an Excel macro to automatically change uppercase to lowercase at the…
- User
I need you to write an Excel macro to automatically change uppercase to lowercase at the beginning of a cell
Assistant
Here's an Excel VBA macro that converts the first character of text cells to lowercase if it's uppercase, while skipping formulas, numbers, and empty cells:
Sub ConvertFirstCharToLower() Dim cell As Range Dim cellText As String Dim firstChar As String ' Speed up execution Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Application.EnableEvents = False On Error GoTo Cleanup ' Ensure settings get restored on error For Each cell In Selection ' Skip if cell contains formula or is empty If Not cell.HasFormula And Not IsEmpty(cell) Then ' Process only text cells If VarType(cell.Value) = vbString Then cellText = cell.Value If Len(cellText) > 0 Then firstChar = Left(cellText, 1) ' Check if first character is uppercase If firstChar <> LCase(firstChar) Then ' Convert first character to lowercase cell.Value = LCase(firstChar) & Mid(cellText, 2) End If End If End If End If Next cell Cleanup: ' Restore settings Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic Application.EnableEvents = True End SubFeatures:
- Only affects text cells (ignores numbers, dates, errors)
- Preserves formulas (won't convert them to values)
- Handles international characters
- Processes entire selection efficiently
- Maintains all formatting
To use:
- Select the cells you want to modify
- Press
Alt + F11to open VBA editor - Insert new module (
Insert > Module) - Paste this code
- Close the editor
- Run the macro via
Developer > Macrosor assign to a button
Examples of conversion:
- "HELLO" → "hELLO"
- "Test" → "test"
- "123Text" → "123Text" (unchanged - starts with number)
- "=UPPER("Hi")" → unchanged (formula)
- "ÄBC" → "äBC" (handles international characters)
Notes:
- Works on English and non-English characters
- Preserves all text after the first character
- Case conversion respects your system's locale settings
- Runs faster on large selections due to optimization settings
To run the macro regularly, you can:
- Assign it to a Quick Access Toolbar button
- Bind it to a keyboard shortcut
- Add it as a button to your ribbon
- Attach it to a shape in your worksheet
Let me know if you need any modifications!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.