Change Text Case
UPPER CASE
Description: A word or sentence is said to be in upper case if its all the letters are in capital letters like this: EXCELITEMS IS BEST COLLECTION OF EXCEL RELATED STUFF.Code:
Sub ChangeUCase()
' This module will change case of selected cells to UPPER CASE.
On Error Resume NextDim MyCell As Range
For Each MyCell In Selection.Cells
MyCell.Value = UCase(MyCell.Value)
Next
On Error GoTo 0
End Sub
lower case
Description: A word or sentence is said to be in lower case if its all the letters are in small letters like this: excelitems is best collection of excel related stuff.
Code:
Sub ChangeLCase()
' This module will change case of selected cells to lower case.
On Error Resume NextDim MyCell As Range
For Each MyCell In Selection.Cells
MyCell.Value = LCase(MyCell.Value)
Next
On Error GoTo 0
End Sub
Proper Case
Description: A word or sentence is said to be in proper case if first letter of each word is in capital letter and rest are in small letters like this: Excelitems Is Best Collection Of Excel Related Stuff.
Code:
Sub ChangePCase()
' This module will change case of selected cells to Proper Case.
On Error Resume NextDim MyCell As Range
For Each MyCell In Selection.Cells
MyCell.Value = WorksheetFunction.Proper(MyCell.Value)
Next
On Error GoTo 0
End Sub
Sentence case
Description: A sentence is said to be in sentence case if first letter of sentence is in capital letter and rest are in small letters like this: Excelitems is best collection of excel related stuff.
Code:
Sub ChangeSCase()
' This module will change case of selected cells to Sentence case.
On Error Resume NextDim MyCell As Range
For Each MyCell In Selection.Cells
If Len(MyCell.Value) >= 2 Then
MyCell.Value = UCase(Left(MyCell.Value, 1)) & LCase(Right(MyCell.Value, (Len(MyCell.Value) - 1)))
End If
Next
On Error GoTo 0
End Sub
ToGgLe CaSe
Description: A word or sentence is said to be in toggle case if first letter of sentence is in capital letter and next is in small letter then next in capital letter and so on like this: ExCeLiTeMs iS BeSt cOlLeCtIoN Of eXcEl rElAtEd sTuFf.
Code:
Sub ChangeTCase()
' This module will change case of selected cells to ToGgLe CaSe.
Dim MyCell As RangeDim i As Integer
On Error Resume Next
For Each MyCell In Selection.Cells
If Len(MyCell.Value) >= 2 And IsNumeric(MyCell.Value) = False And IsEmpty(MyCell.Value) = False And IsNull(MyCell.Value) = False Then
For i = 1 To Len(MyCell.Value) Step 2
MyCell.Characters(i, 1).Text = UCase(MyCell.Characters(i, 1).Text)
Next
For i = 2 To Len(MyCell.Value) Step 2
MyCell.Characters(i, 1).Text = LCase(MyCell.Characters(i, 1).Text)
Next
End If
Next
On Error GoTo 0
End Sub
Post a Comment