Reverse Names in Excel With a Comma: Formula and Steps

Formulas & functions · Updated November 20, 2026

To turn names stored as Last, First into First Last, enter this formula in B2 when the original name is in A2: =TRIM(TEXTAFTER(A2,",")&" "&TEXTBEFORE(A2,",")). For example, Smith, Jane becomes Jane Smith. Fill the formula down to convert the rest of the list. This uses functions available in Microsoft 365 and Excel 2024.

What You’ll Need

  • A worksheet with names in one column, such as A2:A100, and a blank column for the reversed results.
  • Names consistently written with a comma between the two parts, such as Last, First. The formula uses the first comma as the dividing point.
  • Microsoft 365 or Excel 2024 for the TEXTAFTER and TEXTBEFORE formula. If you have an older Excel version, use the alternative formula in Step 5.

Make a copy of the worksheet or keep the original name column unchanged until you have checked the results. That gives you a quick way to recover the source data if the list includes unusual formats.

Step-by-Step

  1. Check the source format. Look at several names in the column, not just the first one. The main formula works when a comma separates the part you want to move to the front from the part you want at the end. For example, Garcia, Elena and van Buren, Alex both follow the pattern. Make sure the comma is present and that it separates the name parts rather than a suffix or another note. If the list includes several different formats, identify those rows before filling a formula through the whole column.
  2. Choose a blank output column. If names are in column A, use B2 for the first result and put a heading such as Reversed Name in B1. Keeping the result beside the original makes it easier to compare spelling and catch exceptions. Avoid placing the formula in A2, because that would overwrite the source name. If the data is an Excel Table, add a new table column and enter the formula in its first data row.
  3. Enter the formula. With the source name in A2 and the first output cell in B2, enter =TRIM(TEXTAFTER(A2,",")&" "&TEXTBEFORE(A2,",")). Press Enter. TEXTAFTER returns the text after the comma, TEXTBEFORE returns the text before it, and the ampersands join those parts with a space. TRIM removes spaces at the beginning or end of the combined result. For Smith, Jane, the result is Jane Smith.
  4. Confirm the result before copying. Compare the new value with the source. For O'Neil, Patrick, the output should be Patrick O'Neil; the apostrophe remains part of the name. For de la Cruz, Maria, the formula returns Maria de la Cruz, preserving the multiword surname as a unit. If your result has an unwanted comma, missing text, or an unexpected order, pause and check the source format before filling the formula down.
  5. Fill the formula down the list. Select B2 and drag the small square at the lower-right corner of the cell down to the last name. If column A is filled continuously, you can also double-click that square and Excel will extend the formula alongside the adjacent data. On Windows, select the formula cell and the cells below it, then press Ctrl+D to Fill Down. In Excel for Mac, Command+D is the usual Fill Down shortcut. Excel for the web supports the formula and fill handle; keyboard shortcuts can vary with browser and operating-system settings.
  6. Use a guarded formula if the list has blanks or missing commas. With source names in A2:A100 and the first result in B2, use =IF(A2="","",IFERROR(TRIM(TEXTAFTER(A2,",")&" "&TEXTBEFORE(A2,",")),"Check comma")). This leaves a blank result when A2 is empty and displays Check comma when the formula cannot find a comma. Fill this version down instead of the simpler formula if blank rows or inconsistent entries are expected. Review any flagged row and correct the source or handle it separately.
  7. Use a formula for older Excel versions if needed. With the source in A2 and the result in B2, this formula uses older functions that are available in many earlier Excel releases: =TRIM(MID(A2,FIND(",",A2)+1,LEN(A2))&" "&LEFT(A2,FIND(",",A2)-1)). It finds the comma, takes the text on each side, joins the parts, and trims extra edge spaces. For Smith, Jane, it returns Jane Smith. This version returns an error if a row has no comma, so check the source list or use IFERROR if you want an error message instead.
  8. Check the whole output before replacing anything. Scan down the results and compare a sample from the top, middle, and bottom of the list. Once the results are correct, you can leave the formulas in place or convert them to fixed text. To make fixed text, copy the result cells, then use Home > Paste > Paste Values. This replaces the formulas with their current displayed results while leaving the original column available for reference.

Common Mistakes

Assuming every name has the same structure. A formula that swaps the two comma-separated parts does not know which part is a first name or surname. It simply moves everything after the first comma to the front and everything before it to the end. That is useful for consistent lists, but a row such as Dr. Smith, Jane becomes Jane Dr. Smith, not a cleaned personal name.

Deleting the comma before converting the list. The comma tells TEXTBEFORE and TEXTAFTER where to divide the text. If it is missing, the basic formula will return an error. Keep the source column intact and use the guarded formula when entries may not all contain a comma.

Expecting the formula to interpret suffixes. A value such as Smith, Jane, Jr. has two commas. The formula divides at the first one, so the output includes the later comma as part of the text moved to the front. Names with suffixes, titles, credentials, or extra notes may need individual cleanup or a separate rule.

Overwriting the originals or copying a formula incorrectly. Put the result in a separate column and use a relative reference such as A2, not a fixed reference that points every row to A2. When you fill down, the formula should refer to A3, A4, and so on.

Tips

Keep the source and converted columns side by side while checking. It is easier to spot a missing comma or an unexpected space when you can compare each result with its original. Filter or sort only after reviewing the output, and avoid sorting just one column because that can separate names from related information in other columns.

TRIM handles extra spaces at the outside edges of the joined result, but it does not fix every spacing issue inside the source. If a name contains multiple spaces between words, check whether those spaces should be corrected. Also remember that a formula changes how the name is displayed, not the person’s official name or the structure of your source data.

If you need to share the converted list without formulas, use Paste Values after checking it. Keep a copy of the original column, especially when working with customer, employee, or mailing records. This lets you revisit a source entry if a spelling or name order is questioned later.

For Mac and Windows, the TEXTAFTER and TEXTBEFORE formula itself is the same in Microsoft 365. Excel for the web also supports these functions. In older desktop versions that do not recognize them, use the older formula in Step 5 or check whether your organization provides a newer Excel version.

Troubleshooting

You see #NAME? Your Excel version may not recognize TEXTAFTER or TEXTBEFORE. Use the older formula in Step 5, or open the workbook in Microsoft 365 or Excel 2024. If Excel highlights a function name as unrecognized, that is a version compatibility issue rather than a problem with the name itself.

You see #N/A or an error on a row. Check whether that cell contains a comma. The modern formula expects one. If the list has blank cells or inconsistent data, use the guarded formula in Step 6 so blanks stay blank and entries without a comma are marked for review. A comma that looks ordinary may also be a different punctuation character copied from another source.

The formula appears as text instead of calculating. Check whether the cell is formatted as Text or whether the formula begins with an apostrophe. Change the cell format to General, edit the cell, and press Enter again. Also confirm that the first character is an equals sign. If calculation is set to manual, use Formulas > Calculation Options > Automatic, then recalculate.

Excel rejects the formula when you enter it. Confirm that quotation marks are straight double quotes and that all parentheses are present. Some regional settings use semicolons between function arguments instead of commas; if Excel flags the separators, replace argument-separating commas with semicolons according to your regional settings. Do not change the comma inside the quoted delimiter ",".

The output order is wrong for only a few rows. Inspect those source entries for titles, suffixes, extra commas, or a format such as First Last without a comma. A two-part swap cannot infer a different rule for exceptional rows. Correct those entries manually in the output or create a separate handling rule, and then verify that no other rows share the exception.

Frequently Asked Questions

Can I reverse names from First Last to Last, First?
Yes, but the formula above is designed for names that already have a comma. For simple two-word entries in A2, you can use =TEXTAFTER(A2," ")&", "&TEXTBEFORE(A2," "). It treats the first space as the divider, so multiword names need review.

Will the formula handle middle names?
If the source is Last, First Middle, the comma-based formula returns First Middle Last. It moves the entire text after the first comma together, so middle names remain with the first-name portion.

Can I reverse the names without a formula?
Data > Text to Columns can split text at a comma, but it does not automatically swap the resulting pieces. You would still need to rearrange or combine the columns. A formula is usually quicker for a long list and updates when the source changes.

Does this change the original names?
No. The formula displays a rearranged result in another cell. The source stays as it was unless you overwrite it or replace it deliberately. Use Paste Values only after you have checked the converted output.

Why does the formula give a strange result for a suffix?
The formula splits at the first comma only. A suffix after a second comma remains in the text after that first comma, so it may move to the front with the given name. Review suffix rows separately rather than assuming the formula can identify their meaning.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.