![]() |
Sentence Case
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 |
Sentence Case
(Source: http://www.angelfire.com/biz7/julian...ans_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 "Alex" wrote: 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 |
Sentence Case
Thanks Sheeloo,
You saved my life, the code is simple and works just great. Thanks again... "Sheeloo" wrote: (Source: http://www.angelfire.com/biz7/julian...ans_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 "Alex" wrote: 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 |
All times are GMT +1. The time now is 11:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com