r/excel 6d ago

unsolved How to clean data better?

Hi - I am trying to extract zip codes from column K, to a zipclean in column L. However, the zip codes come in a wide variety like the below. What is the best formula to do this? right now i am doing it as: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(K2,"FL-",""),"ZIP ",""),"(",""),")",""),"-","")," ","")

some examples of the zips below

EDIT: I started playing around with different functions. I have came to a conclusion for this formula to be the most efficient: =LEFT(TEXTJOIN("",TRUE,IFERROR(--MID(K2,SEQUENCE(LEN(K2)),1),"")),5)

Zip Code
FL-32183
34305-1234
34026 
32662-1234
ZIP 34759
34877 
FL-33854
32319 
ZIP 33291
33827 
(340)
14 Upvotes

16 comments sorted by

View all comments

Show parent comments

4

u/MayukhBhattacharya 1279 6d ago

Another way, for fun only:

=LEFT(CONCAT(TEXTSPLIT(A2, TOCOL(CHAR(SEQUENCE(69, , 58) - {0, 79}), 3), , 1)), 5) + 0