Hello,
I am trying to perform sentence case on a cell with some exceptions.
As an example lets say I have a cell that has the text "MARGARINE IS BETTER THAN BUTTER, TRUE OR FALSE".
I would like to run some VBA to change this too "Margarine is better than butter, TRUE or FALSE".
Currently I have this code:
Sub Sentence_Case()
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
cell.Value = s
Next
End Sub
This returns "Margarine is better than butter, true or false".
I would like the true and false to stay in CAPS and also be able to add other exemptions as needed.
Thanks in advance
Tony
Bookmarks