View Single Post
  #18   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Convert list to UPPER, lower & Proper cases.

For clarity, it doesn't work on paragraphs! That means the cell can
only contain a single sentence.


I'm also wrong about this.., so long as end of sentence punctuation is
"." or "?"! Changing the sub as folows makes it suitable for multiple
sentences/paragraphs...

Sub SentenceCase()
Dim c As Range
Application.ScreenUpdating = False
For Each c In Selection.Cells
s = c.value
Start = True
For i = 1 To Len(s)
Ch = Mid(s, i, 1)
Select Case Ch
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
c.value = s
Next
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion