Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Capitalizing Just a Surname.

Capitalizing Just a Surname

by Allen Wyatt
(last updated June 16, 2017)

4

Cheryl is using a worksheet that has, in column A, client names in the format "Smith, Jane." She would like to capitalize only the surname, as in "SMITH, Jane", leaving the rest of the name unchanged.

If there is one and only one comma that separates the surname from the first name, you can create a formula to do the conversion. Assuming the name is in A1, the formula would be:

=UPPER(LEFT(A1,FIND(",",A1)-1))&MID(A1,FIND(",",A1),LEN(A1))

If you prefer to not use a formula (which may mess up the look of your worksheet), you could also use a macro to convert the names, in place. Consider the following:

Sub CapitalizeSurnames()
    Dim rCell As Range
    Dim iComma As Integer
    For Each rCell In Selection
        iComma = InStr(rCell, ",")
        If iComma > 0 Then
            rCell = UCase(Left(rCell, iComma - 1)) & _
              Mid(rCell, iComma)
        End If
    Next
    Set rCell = Nothing
End Sub

Simply select the cells that you want to convert (such as those in column A) and then run the macro. It makes the conversion to the names in the cells.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12639) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Capitalizing Just a Surname.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Creating a Table of Authorities

In legal documents a table of authorities is a common element. Creating the table is easy to do if you apply the techniques ...

Discover More

Understanding DATE Field Formatting

One of the most commonly used fields is the DATE field. You can specify how the DATE field displays the current date by using ...

Discover More

Smart Quotes are Incorrectly Replaced

Not able to replace smart quotes as you want? Here are some ways that you can be sure that every smart quote is changed, ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Easily Dividing Values by 1000

Sometimes the data in a worksheet isn't in the exact format desired. If you want to dividie your values by 1,000, there are a ...

Discover More

Deleting Duplicate Columns

Got a worksheet in which there may be entire columns that are duplicates of each other? If you want to delete those duplicate ...

Discover More

Undoing an Edit

We all make mistakes. Fortunately, Excel makes it rather easy to undo your makes, right after you make them.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 - 0?

2017-06-18 13:22:53

Willy Vanhaelen

Here is a one line macro that does the job.

Sub CapitalizeSurnames()
Selection = Evaluate(Replace("IF(ISERROR(FIND("","",@)),@,UPPER(LEFT(@,FIND("","",@)-1))&MID(@,FIND("","",@),LEN(@)))", "@", Selection.Address))
End Sub


2017-06-17 06:27:49

John

Ah, good point.

I read it completely the wrong way and didn't test it either. Unforgiveable. :-)

Thanks for the correction - I'll be more careful when commenting (and reading!) in future.

John


2017-06-16 09:15:45

Bryan Marks

John, you raise a good point about the complexity involved with the capitalization of last names. However, the point of this tip is to capitalize the entire surname (e.g., "de la Croix" would become "DE LA CROIX", "Macdonald" would become "MACDONALD"). The code above does just that.


2017-06-16 05:18:34

John

This is far too simplistic - what about, say, 'de la Croix', or 'd'Oliviera', or 'Macdonald' and 'MacDonald'. It's pretty much impossible to cover every possibility, particularly as some surnames with exactly the same letters are capitalised differently depending on the person whose surname it is! I guess this is a reasonable approximation but definitely not a comprehensive solution.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.