Capitalize only the first letter in text string

ChrisHT

New Member
Joined
Dec 2, 2008
Messages
2
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
 
Why not use <> 0 then you don't need the Goto?

Code:
Sub CapsFirstLetter()

Dim Cell As Variant
For Each Cell In Selection
    
    If Len(Cell.Text) <> 0 Then 
    
    Cell.Formula = UCase(Left(Cell.Text, 1)) & LCase(Right(Cell.Text, Len(Cell.Text) - 1))

    End If

Next

End Sub
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
A couple of points.

There is no need for .Formula because you are not returning a formula. Also, you can shorten that last bit quite a bit by using Mid instead.

Code:
Sub CapsFirstLetter()
Dim Cell As Range
For Each Cell In Selection
    If Cell <> "" Then Cell = UCase(Left(Cell, 1)) & LCase(Mid(Cell, 2))
Next
End Sub
 
Last edited:
Upvote 0
up votdown vote​
You can also copy necessary data into a Microsoft Word document and change the letter cases using the "Aa" button in the Home > Font tab. Then just copy and paste back into Excel.

Or using the formula:

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


<tbody style="margin: 0px; padding: 0px; border: 0px;">
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,619
Messages
6,125,875
Members
449,267
Latest member
ajaykosuri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top