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

Full Path Names in Headers or Footers

Using a macro to add the full path name into a header or footer in an Excel worksheet.

Discover More

Suppressing Headers or Footers

Don't want a header or footer to appear on just a portion of your document? It's easy to do when you understand that headers ...

Discover More

Shrinking Cell Contents

Need to cram a bunch of text all on a single line in a cell? You can do it with one of the lesser-known settings in Excel.

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Limiting Number of Characters in a Cell

Need to limit the number of characters that can be entered into a cell? One easy way to do it is through the use of Data ...

Discover More

Can't Enter Years in a Cell

Sometimes getting the right thing to show up in a cell can be a bit tricky when working with dates. If you enter a year ...

Discover More

Quickly Filling a Column

Excel has a great (and little known) shortcut for filling a column with information. It comes in very handy when you need to ...

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 + 8?

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.