Sentence Case

A

Alex

Hi,

I tried several posted macros for Sentence Case to make every first letter
of every sentence in a cell - Capital one. No success. Every time I get the
same result: #NAME?
Is there any easy way to do that?

Thanks,
Alex
 
S

Sheeloo

(Source: http://www.angelfire.com/biz7/julian_s/julian/julians_macros.htm)
<To change text in a selected range to sentence case use this code. This
code was supplied by Simon Huggins. >

Sub SentenceCase()
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
 
A

Alex

Thanks Sheeloo,

You saved my life, the code is simple and works just great.

Thanks again...
 

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