FormulaCraft

How to extract a zip code from an address in Excel and Google Sheets

Topic:Text manipulation

Heads up: Excel and Google Sheets do this differently.

Excel
=RIGHT(TRIM(A2),5)
Google Sheets
=REGEXEXTRACT(A2,"\d{5}(?:-\d{4})?$")

Verified example

Computed by a real spreadsheet engine on the sample data below.

Address
123 Main St, Austin, TX 78701
456 Oak Ave, Miami, FL 33101
789 Pine Rd, Denver, CO 80201
321 Elm Blvd, Seattle, WA 98101

=RIGHT(TRIM(A2),5)78701

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Confirm your address column ends with the ZIP code (standard US format: City, ST ZIPCODE).
  2. 2In Excel use =RIGHT(TRIM(A2),5) to grab the last five characters — this works when ZIP codes are always 5 digits at the end.
  3. 3For ZIP+4 codes (e.g., 78701-1234) in Excel use =MID(TRIM(A2),LEN(TRIM(A2))-9,10) or just =RIGHT(TRIM(A2),10).
  4. 4In Google Sheets =REGEXEXTRACT(A2,"\d{5}(?:-\d{4})?$") robustly extracts 5-digit or ZIP+4 codes.
  5. 5Copy the formula down for all rows.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

What if the ZIP code is in the middle of the address?

Use Google Sheets' REGEXEXTRACT with \b\d{5}\b to find the first 5-digit sequence regardless of position. In Excel use a combination of FIND with MID targeting digits.

Does RIGHT() work for ZIP codes with a leading zero (e.g., 02101)?

Yes, RIGHT() returns a text string so leading zeros are preserved. Make sure the ZIP code column is formatted as Text if you store the result.

More on Text manipulation

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: