How to change the casing of the letters in an excel cell?

B

Billy Liddel

Syed Mohideen said:
shortcut for changing casing

Syed

No shortcut in Excel I'm afraid. You have to use functions

Proper(This Is the Text Result)
Lower(this is the text result)
Upper(THIS IS THE TEXT RESULT)

To change the text in place you woud have to use a macro similar to this:

Sub changeCase()
Dim rsp, c
rsp = InputBox("Enter U, P or L to choose Upper, Proper or Lower case")
For Each c In Selection
If UCase(rsp) = "U" Then
c.Value = UCase(c)
ElseIf UCase(rsp) = "P" Then
c.Value = Application.WorksheetFunction.Proper(c)
ElseIf UCase(rsp) = "L" Then
c.Value = LCase(c)

End If
Next
End Sub

You can assign a shortcut to the macro for ease of use.

Regards
Peter
 
G

Gord Dibben

Syed

Note that Billy's macro will destroy any formulas you may have in the range and
turn them into values only.

If you might have formulas in the selected range, change to.................

Sub changeCase()
Dim rsp, c
rsp = InputBox("Enter U, P or L to choose Upper, Proper or Lower case")
For Each c In Selection
If UCase(rsp) = "U" Then
c.Formula = UCase(c.Formula)
ElseIf UCase(rsp) = "P" Then
c.Formula = Application.WorksheetFunction.Proper(c.Formula)
ElseIf UCase(rsp) = "L" Then
c.Formula = LCase(c.Formula)
End If
Next
End Sub


Gord Dibben MS Excel MVP
 
Top