Written by Allen Wyatt (last updated March 8, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
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.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12639) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Capitalizing Just a Surname.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
If you have a lot of text in your workbook, at some point you might want to split out sentences into individual cells. ...
Discover MoreThe easy way to get rid of spaces at the beginning or end of a cell's contents is to use the TRIM function. ...
Discover MoreDo you need to paste formulas without updating the references in whatever you are pasting? You can accomplish this, ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-03-09 05:23:59
Philip
The "Mid" function doesn't need the "Len" argument in this case (if the last argument in Mid is omitted, by default the full remainder of the text from the "starting position" is returned)
2020-11-28 05:11:12
Rick Rothstein
Although it is kind of long, we can upper case the last name all of the selected cells using this one-liner macro (assuming the last name is always separated from the rest of the name with a comma)...
Sub UpperCaseLastNameOnly()
Selection = Evaluate(Replace("IFERROR(UPPER(LEFT(@,FIND("","",@&"","")))&MID(@,FIND("","",@)+1,99),"""")", "@", Selection.Address))
End Sub
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments