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

Printing More than One Copy

If you need to print more than one copy of your document, you need to become familiar with the printing options made ...

Discover More

Finding and Changing Word's Internal Commands

If you know how to create macros, you can easily create entire replacements for Word's internal commands. Here's all you need ...

Discover More

Slowing Down Mouse Selection

We've all experienced the problem: You start selecting a large block of text using the mouse, and before you know it the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Ensuring Rows and Columns are Empty

Before you go about deleting rows and columns helter-skelter, it is a good idea to determine if there is anything in the row ...

Discover More

Requiring Input

If you distribute a workbook that is used by others for data entry, you may want a way to make sure they fill in certain ...

Discover More

Quickly Entering Dates and Times

Excel provides keyboard shortcuts for a variety of purposes. This tip examines two such shortcuts, designed to allow entering ...

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 3 - 2?

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.