ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Capitalize only first letter in sentence (https://www.excelbanter.com/excel-worksheet-functions/212274-capitalize-only-first-letter-sentence.html)

ChrisHT

Capitalize only first letter in sentence
 
In Excel 2003, I am referencing a text string and would like to return the
text string with only the first letter capitalized. The PROPER function does
not do this, as it capitalizes the first letter of every word. The formula
below does however perform this, but I would like to write it as a
User-Defined Function, similar to the Proper function, so it can be applied
to multiple different workbooks:

=UPPER(LEFT(A1,1))&LOWER(RIGHT(A1,LEN(A1)-1))

Is it even possible to write a User-Defined Function to complete this
seemingly simple task and, if so, how do I do it?

Thanks,
Chris

Chip Pearson

Capitalize only first letter in sentence
 
Try code like

Function ChangeCase(S As String) As String
ChangeCase = UCase(Left(S, 1)) & LCase(Mid(S, 2))
End Function

Then, call it from a cell with

=ChangeCase(A1)


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Tue, 2 Dec 2008 13:18:01 -0800, ChrisHT
wrote:

In Excel 2003, I am referencing a text string and would like to return the
text string with only the first letter capitalized. The PROPER function does
not do this, as it capitalizes the first letter of every word. The formula
below does however perform this, but I would like to write it as a
User-Defined Function, similar to the Proper function, so it can be applied
to multiple different workbooks:

=UPPER(LEFT(A1,1))&LOWER(RIGHT(A1,LEN(A1)-1))

Is it even possible to write a User-Defined Function to complete this
seemingly simple task and, if so, how do I do it?

Thanks,
Chris



All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com