Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Pull out zip code?

Posted on 2014-10-10
Medium Priority
93 Views
I have addresses in a cell that is the below format. How do I pull out just the zip code?

2725 Agoura Rd, Thousand Oaks, CA 91361
0
Question by:cansevin
• 3

LVL 37

Expert Comment

ID: 40373568
if the addresses are for US only and the zip codes are always at the end of the addresses after their two-letter state name, you may simply extract the 5-digit zip codes by using string functions.
0

LVL 27

Accepted Solution

ProfessorJimJam earned 2000 total points
ID: 40373576
=UPPER(TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",99)),99)))
0

LVL 27

Expert Comment

ID: 40373600
in case if you want to pull the two digit State, let me save you time , and cover it also in this thread to pull only State CA  then here is formula   =UPPER(MID(A1,FIND(",",A1,1)+2,2))
0

LVL 27

Expert Comment

ID: 40373801
Cool function, ProfessorJimJam, for pulling out the zip code.

No points, but....
The function to pull the state code doesn't work (shows first two letters of city in uppercase), but this formula will show the state code:
=RIGHT(LEFT(A1,LEN(A1)-LEN(TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",99)),99)))-1),2)

Note that it uses the LEN of the result found for the zip code as part of this.

-Glenn
0

LVL 27

Expert Comment

ID: 40373815
Thank you Glenn.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month11 days, 12 hours left to enroll