Advertisement
crexin

Excel - generic way to split Address from one column into multiple columns.

Oct 30th, 2023 (edited)
4,604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Assume Address data is in Column E and has data like "123 Any ST Anytown NY 12345"
  2.  
  3. First Zipcode match for K2 = Right(E2,5)
  4. Or Combined to match all in one shot -
  5. =IF(COUNTIF(E2,"*-*"),RIGHT(E2,10),RIGHT(E2,5))
  6.  
  7. Zip Code matching - figure out if it has a 9 digit code instead of 5
  8. =IF(COUNTIF(K2,"*-*"),RIGHT(E2,10),K2)
  9.  
  10.  
  11. Find position of last space in string
  12.  
  13. =FIND("?",SUBSTITUTE(E2," ","?",LEN(E2)-LEN(SUBSTITUTE(E2," ",""))))
  14.  
  15. From <https://www.bing.com/search?q=excel+find+position+of+last+space+in+string&qs=UT&pq=excel+find+position+of+last+space&sc=10-33&cvid=385C46DC879C40EDBC2AAA61EA4896DF&FORM=QBRE&sp=1&ghc=1&lq=0>
  16.  
  17. Find state:
  18.  
  19. =MID(E2,FIND("?",SUBSTITUTE(E2," ","?",LEN(E2)-LEN(SUBSTITUTE(E2," ",""))))-2,2)
  20.  
  21.  
  22.  
  23. Find 2nd to last space:
  24.  
  25. =FIND("/",SUBSTITUTE(E2," ","/", LEN(E2)- LEN(SUBSTITUTE(E2," ",""))-1))
  26.  
  27. From <https://excelnotes.com/how-to-locate-the-last-space-in-the-text-string/>
  28.  
  29. Third to last space
  30.  
  31. =FIND("/",SUBSTITUTE(E2," ","/",LEN(E2)-LEN(SUBSTITUTE(E2," ",""))-2))
  32.  
  33. From <https://excelnotes.com/how-to-locate-the-last-space-in-the-text-string/>
  34.  
  35.  
  36. =MID(E2,
  37. FIND("/",SUBSTITUTE(E2," ","/", LEN(E2)- LEN(SUBSTITUTE(E2," ",""))-1)),FIND("/",SUBSTITUTE(E2," ","/",LEN(E2)-LEN(SUBSTITUTE(E2," ",""))-2))-FIND("/",SUBSTITUTE(E2," ","/", LEN(E2)- LEN(SUBSTITUTE(E2," ",""))-1)))
  38.  
  39.  
  40. Find City
  41.  
  42. I2 = Pos 2nd to last space = =FIND("/",SUBSTITUTE(E2," ","/", LEN(E2)- LEN(SUBSTITUTE(E2," ",""))-1))
  43. J2 = Pos3rdtolastspace = =FIND("/",SUBSTITUTE(E2," ","/",LEN(E2)-LEN(SUBSTITUTE(E2," ",""))-2))
  44. =MID(E2,J2,I2-J2)
  45.  
  46.  
  47.  
  48. Only about 20 didn't match the city
  49.  
  50. Street Address formula (in column H)
  51.  
  52. =MID(E2,1,I2)
Tags: excel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement