Cellwise Start free

Excel guide · 5 min read

How to split an address into columns in Excel

Quick answerCount from the end of the address, where the parts are always the same. =TEXTAFTER(A2," ",-1) is the ZIP (the last word), =LEFT(TRIM(TEXTAFTER(A2,",",-1)),2) the state, =TRIM(TEXTBEFORE(TEXTAFTER(A2,",",-2),",")) the city, and =TEXTBEFORE(A2,",",-2) the street, including any Suite or Apt line. These need Excel 365 or Excel 2024.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

A
1Address
212 Elm St, Springfield, IL 62704
3480 Market Street, Suite 210, San Francisco, CA 94105
477 Harbor Rd, Portland, ME 04101
59 Pine Ave, Austin, TX 78701-2315
61500 Lake Shore Dr Apt 5B, Chicago, IL 60610
7301 Oak Lane,Boulder, CO 80302

Download this sheet as an Excel practice file (.xlsx)

Why a plain split goes wrong

A customer list came from a web form with the whole address in one cell. You need street, city, state and ZIP in separate columns for a mail merge or a shipping upload.

The obvious formula is =TEXTSPLIT(A2,", "), and for "12 Elm St, Springfield, IL 62704" it works: three parts. But real data isn't that tidy. The San Francisco address has a Suite line, so it splits into four parts and the city lands in the state column. The Boulder address has no space after the first comma, so splitting on ", " gives only two parts.

=TRIM(TEXTSPLIT(A7,",")) fixes the missing space: split on the comma alone, then TRIM the spaces. It still leaves the state and ZIP together, and it still shifts columns when a Suite line appears. The fix is to count from the right.

=TEXTSPLIT(A3,", ")

Result: spills 1 row × 4 columns

480 Market StreetSuite 210San FranciscoCA 94105

Four parts: 480 Market Street, Suite 210, San Francisco, CA 94105. The extra line pushes everything over.

ZIP and state: the end of the address

TEXTAFTER with a negative instance number counts delimiters from the end. =TEXTAFTER(A2," ",-1) returns everything after the last space, which is always the ZIP: 62704.

The state is after the last comma. TEXTAFTER(A2,",",-1) gives " IL 62704", TRIM removes the leading space, and LEFT(...,2) keeps the two-letter code: IL. If your list includes longer state names, use =TEXTBEFORE(TRIM(TEXTAFTER(A2,",",-1))," ",-1) instead, which keeps everything before the ZIP.

=TEXTAFTER(A2," ",-1)

Result: 62704

62704: the last word of the address.

City and street, even with a Suite line

The city is always between the second-to-last comma and the last one. TEXTAFTER(A3,",",-2) gives " San Francisco, CA 94105", TEXTBEFORE(...,",") cuts it at the next comma, and TRIM tidies it: San Francisco.

The street is everything before the second-to-last comma: =TEXTBEFORE(A3,",",-2). For the San Francisco row that's "480 Market Street, Suite 210", so the Suite line stays with the street, where a label or shipping form expects it. For the plain rows it's just the street, like 12 Elm St.

If you need the unit in its own column and it's written inside the street, as in "1500 Lake Shore Dr Apt 5B", split on the word: =TEXTBEFORE(A6," Apt ") gives 1500 Lake Shore Dr and =TEXTAFTER(TEXTBEFORE(A6,","),"Apt ") gives 5B. Wrap them in IFERROR for rows with no Apt.

=TRIM(TEXTBEFORE(TEXTAFTER(A3,",",-2),","))

Result: San Francisco

San Francisco: found by counting commas from the right, so the Suite line doesn't matter.

All four columns for the whole list

In Excel 365, give each formula the whole range and HSTACK the results side by side. One formula fills the table for every row: the Suite line stays with its street, Boulder is found despite the missing space, and the Austin ZIP+4 78701-2315 is trimmed to 78701 by LEFT(...,5).

Keep the ZIPs as text. TEXTAFTER returns text, so Portland's 04101 keeps its leading zero (=ISTEXT shows TRUE). If you convert it with VALUE or --, it becomes 4101. If ZIPs have already lost their zeros, =TEXT(4101,"00000") brings back 04101.

If some addresses don't follow the street, city, state ZIP pattern at all (a PO box with no commas, or a country at the end), the formulas return #N/A or the wrong piece. Filter for those rows and fix them by hand, or paste a sample into Cellwise Fix (cellwise.app/excel-formula-helper/) to get a formula for your exact format.

=HSTACK(TEXTBEFORE(A2:A7,",",-2),TRIM(TEXTBEFORE(TEXTAFTER(A2:A7,",",-2),",")),LEFT(TRIM(TEXTAFTER(A2:A7,",",-1)),2),LEFT(TEXTAFTER(A2:A7," ",-1),5))

Result: spills 6 rows × 4 columns

12 Elm StSpringfieldIL62704
480 Market Street, Suite 210San FranciscoCA94105
77 Harbor RdPortlandME04101
9 Pine AveAustinTX78701
1500 Lake Shore Dr Apt 5BChicagoIL60610
301 Oak LaneBoulderCO80302

Street, city, state and 5-digit ZIP for all six addresses, Suite line and 04101 included.

No formulas: Text to Columns or Flash Fill

In older Excel, or for a one-off cleanup, Text to Columns splits on the comma. It changes the data in place, so work on a copy of the column.

Flash Fill also works on tidy lists: type the city for the first two rows next to the addresses, then press Ctrl+E. Check the results, because Flash Fill guesses from your examples and tends to stumble on the Suite and Apt rows.

  1. Copy the address column to a spare column and select it.
  2. Data > Text to Columns > Delimited > Next.
  3. Tick Comma (and untick Tab), then Next.
  4. Click the column that will hold "IL 62704" and choose Column data format: Text, so ZIPs keep their leading zeros. Click Finish.
  5. To separate state and ZIP, select that column and run Text to Columns again with Space as the delimiter, again setting the ZIP column to Text. Then use Home > Find & Select > Replace or TRIM to remove the leading spaces left by the first split.

Common mistakes

Splitting on ", " (comma and space)

One missing space breaks the split. Split on "," and wrap the result in TRIM.

Counting from the left

An optional Suite or Apt line shifts every column after it. Count from the right with negative instance numbers in TEXTAFTER and TEXTBEFORE.

ZIP codes losing leading zeros

Keep ZIPs as text: don't wrap TEXTAFTER in VALUE, and set the ZIP column to Text in Text to Columns. Repair lost zeros with TEXT(A2,"00000").

ZIP+4 in a 5-digit field

78701-2315 won't fit a 5-digit ZIP field. LEFT(zip,5) keeps the first five digits.

FAQ

How do I separate city, state and ZIP in Excel?

If they're in one cell like "Springfield, IL 62704", use =TEXTBEFORE(A2,",") for the city, =LEFT(TRIM(TEXTAFTER(A2,",")),2) for the state and =TEXTAFTER(A2," ",-1) for the ZIP.

How do I split an address with no commas?

Without a delimiter, Excel can't tell where the street ends and the city begins, because both can have several words. The ZIP and state are still the last two words: =TEXTAFTER(A2," ",-1) and =TEXTBEFORE(TEXTAFTER(A2," ",-2)," "). The rest usually needs Flash Fill or a manual fix.

How do I split an address in Excel 2016 or 2019?

TEXTBEFORE and TEXTAFTER aren't available there. Use Data > Text to Columns on the comma, or the older FIND, MID and LEFT approach shown in the split text by delimiter guide.

How do I combine the columns back into one address?

Use =TEXTJOIN(", ",TRUE,B2,C2,D2&" "&E2) to join street, city and "state ZIP". TRUE skips empty cells, so a missing line doesn't leave a double comma.

Functions used

Related guides

Updated