Word 有「變更大小寫」功能,Excel 卻無內建對應指令,僅能靠 UPPER/LOWER/PROPER 公式或手動修改。
Click 事件代碼:Sub CommandButton1_Click()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If VarType(c.Value) = vbString Then
c.Value = UCase(c.Value)
End If
Next c
End Sub
Sub CommandButton2_Click()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If VarType(c.Value) = vbString Then
c.Value = LCase(c.Value)
End If
Next c
End Sub
Sub CommandButton3_Click()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If VarType(c.Value) = vbString Then
c.Value = StrConv(c.Value, vbProperCase) ' 或自寫邏輯
End If
Next c
End Sub
Sub CommandButton4_Click()
Dim rng As Range, c As Range
Set rng = Selection
For Each c In rng
If VarType(c.Value) = vbString Then
c.Value = WorksheetFunction.Proper(c.Value)
End If
Next c
End Sub


StrConv(..., vbProperCase) 與 WorksheetFunction.Proper 效果相似,但對中文標點處理不同,實測以 Proper 較穩定。If VarType(c.Value) = vbString Then 判斷,避免數值/日期/錯誤值被轉換導致資料損壞。