How do I Change Case or tOGGLE cASE in Excel?

E

Excel Phobic

How do we Change Case to UPPER, Titel, Sentence, lower and tOGGLE case for
text within Excel?
Seems a simple one that MS would have taken care of by now.
Do we still have to take the data to MS Word and then change case (Shift+F3)
and then bring it back?
 
G

Gord Dibben

You can use the functions upper, lower or proper in helper cells.

Or use macros to make the changes in place.

Sub Upper()
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In Selection
Cell.Formula = UCase(Cell.Formula)
Next
Application.ScreenUpdating = True
End Sub


Sub Lower()
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In Selection
Cell.Formula = LCase(Cell.Formula)
Next
Application.ScreenUpdating = True
End Sub


Sub Proper()
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In Selection
Cell.Formula = Application.Proper(Cell.Formula)
Next
Application.ScreenUpdating = True
End Sub

Sub Sentence()
For Each Cell In Selection.Cells
S = Cell.Value
Start = True
For I = 1 To Len(S)
ch = Mid(S, I, 1)
Select Case ch
Case "."
Start = True
Case "?"
Start = True
Case "a" To "z"
If Start Then ch = UCase(ch): Start = False
Case "A" To "Z"
If Start Then Start = False Else ch = LCase(ch)
End Select
Mid(S, I, 1) = ch
Next


Gord Dibben MS Excel MVP
Cell.Value = S
Next
End Sub

On Wed, 17 Jun 2009 23:26:01 -0700, Excel Phobic <Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top