Splitting addresses

Liverlee

Board Regular
Joined
Nov 8, 2018
Messages
73
Office Version
  1. 2019
Platform
  1. Windows
Hello All

I've thousands of addresses in column A that need splitting because they are too long. Some addresses are 31 characters in length and others are up to 100 characters in length. There are no commas or semi-colons that split the addresses sadly. There are random amounts of spaces between each text string some may have the first space after 3 characters like a house number "103" and for some addresses, the first space might be after 13 characters i.e "apartment 103", it's all completely random.

So for example i may have two addresses
In A1 - '1600 Pennsylvania Avenue NW Washington DC 20500 USA' has 7 spaces in the 51-character text string
In A2 - '1 Buckingham palace London England' has 4 spaces in a 34-character text string

Is there a way to split a cell text string to the last space before 30 characters with a comma but not through a whole word? so in the above case there'd be a comma inserted after 'NW'

i've tried =LEFT(A1,FIND(" ",A1,FIND(" ",A1)+1)-1)&", "&RIGHT(A1,LEN(A1)-FIND(" ",A1,FIND(" ",A1)+1)) and =LEFT(A1,29)&","&RIGHT(A1,LEN(A1)-29)

Any and all suggestions are welcome, racking my brain on a Saturday evening trying to come up with a solution.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have 365 with the latest functions, how about
Fluff.xlsm
AB
11600 Pennsylvania Avenue NW Washington DC 20500 USA1600 Pennsylvania Avenue NW, Washington DC 20500 USA
21 Buckingham palace London England1 Buckingham palace London, England
Main
Cell Formulas
RangeFormula
B1:B2B1=LET(a,TEXTBEFORE(LEFT(A1,30)," ",-1),a& ","& SUBSTITUTE(A1,a,""))
 
Upvote 0
:confused: Then why did you say you had sorted a previous question with "=textafter(a2,"*",-1)" as that doesn't exist in 2019?
 
Upvote 0
I have access to office 365 via work.
So ...
  • Perhaps update your account details to include both versions and/or explain in your post what version(s) you want the answer for.
  • Did the suggestion in post #2 work for you?
Another possibility might be

22 10 16.xlsm
AB
11600 Pennsylvania Avenue NW Washington DC 20500 USA1600 Pennsylvania Avenue NW, Washington DC 20500 USA
21 Buckingham palace London England1 Buckingham palace London, England
323 Short address23 Short address
Split Address
Cell Formulas
RangeFormula
B1:B3B1=IF(LEN(A1)>30,REPLACE(A1,LEN(TEXTBEFORE(LEFT(A1,30)," ",-1))+1,0,","),A1)
 
Upvote 0
Try this ARRAY formula.
A2 is data . In B2
Excel Formula:
=REPLACE(A2,MAX(IF(MID(A2,ROW(1:30),1)=" ",ROW(1:30),"")),1,", ")
To enter ARRAY formula
Copy and paste the formula in cell
Press F2
Press Ctrl+Shift+Enter together
Excel covers the formula with {}.
 
Upvote 0
thankyou for all responding, I spent today trying all your suggested formulas to split the 100k addresses from an old legacy system 😵‍💫 that's even more out of date than myself 😁
and with your help it was done in a couple of clicks. 🙏 bless you all.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top