Word 有「變更大小寫」功能 (Shift+F3),Excel 卻無內建。手動修改或公式 (`UPPER`/`LOWER`/`PROPER`) 需額外欄位再貼回,極不便。
Alt+F11 開啟 VBE → 插入 → 模組,貼入以下代碼:
' === 全部大寫 ===
Sub AllUpper()
Dim rng As Range, cell As Range
Set rng = Selection
For Each cell In rng
If VarType(cell.Value) = vbString Then
cell.Value = UCase(cell.Value)
End If
Next cell
End Sub
' === 全部小寫 ===
Sub AllLower()
Dim rng As Range, cell As Range
Set rng = Selection
For Each cell In rng
If VarType(cell.Value) = vbString Then
cell.Value = LCase(cell.Value)
End If
Next cell
End Sub
' === 句首字母大寫 (僅第一個字母) ===
Sub SentenceCase()
Dim rng As Range, cell As Range, txt As String
Set rng = Selection
For Each cell In rng
If VarType(cell.Value) = vbString Then
txt = LCase(cell.Value)
If Len(txt) > 0 Then
txt = UCase(Left(txt, 1)) & Mid(txt, 2)
End If
cell.Value = txt
End If
Next cell
End Sub
' === 單字首字母大寫 (PROPER 效果) ===
Sub ProperCase()
Dim rng As Range, cell As Range
Set rng = Selection
For Each cell In rng
If VarType(cell.Value) = vbString Then
cell.Value = Application.WorksheetFunction.Proper(cell.Value)
End If
Next cell
End Sub
Excel 2003/2007/2010/2013/2016/2019/365 (含 Mac 版,但 ActiveX 按鈕不支援 Mac,請用表單控制項按鈕)。