Have you ever needed to change the case of text in selected cells within an Excel spreadsheet? After searching the Internet, I found something close then modified it to meet my needs. Others may need to do the same so here is the macro that I ended up with.
Sub Change_Case()
Dim ocell As Range
Dim Ans As String
Ans = Application.InputBox("Type in Letter" & vbCr & _
"(L)owercase, (U)ppercase, (S)entence, (T)itles ")
If Ans = "" Then Exit Sub
If TypeName(Selection) <> "Range" Then Exit Sub
For Each ocell In Selection
Select Case UCase(Ans)
Case "L": ocell = LCase(ocell.Text)
Case "U": ocell = UCase(ocell.Text)
Case "S": ocell = UCase(Left(ocell.Text, 1)) & _
LCase(Right(ocell.Text, Len(ocell.Text) - 1))
Case "T": ocell = Application.WorksheetFunction.Proper(ocell.Text)
End Select
Next
End Sub
I only needed it to force all upper or all lower case. I have not tested the other options so use it at your own risk.
Why Go is Going Nowhere
-
Go, the ancient board game that China, Japan and South Korea all claim as
part of their cultural heritage, is struggling to expand its global
footprint bec...
16 minutes ago

No comments:
Post a Comment