In this Article

*This tutorial will demonstrate how to switch first and last names in Excel and Google Sheets.*

## Switch First and Last Names

Typically names are stored in one of two formats:

- Last Name, First Name
- First Name Last Name

Using Excel formulas we can switch the names around.

This formula will switch names from the first format to the second:

1 |
=MID(B3&" "&B3,SEARCH(" ",B3)+1,LEN(B3)-1) |

We will walkthrough this below.

### SEARCH Function

First, we will use the SEARCH function to show us the position of the space within the name:

1 |
=SEARCH(" ", B3)+1 |

We add plus 1 to the formula to get the position of the beginning letter of the first name.

We will then use the LEN function to return the number of characters in a cell.

### LEN Function

The LEN Function will return the number of characters in a cell.

1 |
=LEN(B3) |

## MID Function – Return Characters From the Middle of a Text String

Now we can use the MID function to populate a text string, and return the characters from the middle of the string based on the positions we have stipulated (Find Space and Len).

1 |
=MID(B3&" "&B3,C3,D3-1) |

Combining these functions yields the original formula.

1 |
=MID(B3&" "&B3,SEARCH(" ",B3)+1,LEN(B3)-1) |

## Switch Last and First Names

You can also flip the text the other way and add in the comma using this formula:

1 |
=MID(B3&", "&B3,SEARCH(" ",B3)+1,LEN(B3)+1) |

## Switch First & Last Names w/ Commas in Google Sheets

These formulas work exactly the same in Google Sheets as in Excel.