Fix Address field

Bud2014

New Member
Joined
Jan 21, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I've been asked to clean up a spreadsheet with 34,000 lines as the addresses are all grouped in one column. Only space separators, some commas, but not enough to use the text to column feature.
I have looked at quite a few of the VBA answers, but I am hopeless lost.

I have tried text to columns with spaces, but it will still require touching everything
Address
1205 Madera Ave Madera 93637 US
3031 Franklin Blvd 95818-3938 US
28200 Wescott Ct 92596 US
FAITH BAPTIST TABERNACLE 32696-0000 US
3348 EDGEWOOD AVENUE 33916 US
1218 West St 96021-2943 US
109 S BROAD STREET 34601-0000 US
1210 W ROBINSON ST 32805 US
6910 STIRLING RD 33024 US
18335 Johnson Rd 96080-9467 US
2353 Fifth Ave 94518-1163 US
8510 WEST FLAGLER ST 33144 US

I also tried to use the XL2BB add in with no luck... my skills are limited. Thanks you for any help that can be provided.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I'd be surprised if the application of any vba logic resulted in a 100% accurate solution. From what you posted it looks like that logic would be along the lines of

If 1st character is numeric presume that it is the address number. In that case,
- find the first space and assume what lies to the left is the address number
- find 2 spaces from the right and assume what lies between first space and that point is the street info
- get the last 2 characters for the country code if can only be 2 characters, or find the next space and what comes after is country code

If the first character is not numeric, anything to the left of the first space is the addressee name. What lies between that point and 2 spaces from the right is the zip code. Same approach as before, but now you probably have to worry about the zip code in the second example being in the wrong column when it is parsed. I imagine there would be other issues as well.

Doable, but would take some work. If you want to take a crack at it, look at these functions, which you'd have to use while looping over rows:
- Instr to find first space from left
- InstrRev to find 2nd space from right
- Left and Mid to parse the string bits
and code that parses these values to columns
HTH
 
Upvote 0
Solution
You don't show what your expected outcome is. You can get to the below with just a few clicks using Power Query.
Would that be any good to you ?

Book1
CDE
1Address.1.1Address.1.2Address.2
21205 Madera Ave Madera93637US
33031 Franklin Blvd95818-3938US
428200 Wescott Ct92596US
5FAITH BAPTIST TABERNACLE32696-0000US
63348 EDGEWOOD AVENUE33916US
71218 West St96021-2943US
8109 S BROAD STREET34601-0000US
91210 W ROBINSON ST32805US
106910 STIRLING RD33024US
1118335 Johnson Rd96080-9467US
122353 Fifth Ave94518-1163US
138510 WEST FLAGLER ST33144US
Sheet1
 
Upvote 0
If one was doing text to columns 1205 would be in the first column. Not sure if that is what is wanted (as you say, no example given) but I presume PQ can do that. If so, what would happen to C5 if doing that made 4 columns?
I do have code for this but it looks like PQ (which I know nothing about) would be the way to go. It sure was complicated (for me, at least).
 
Upvote 0
If one was doing text to columns 1205 would be in the first column. Not sure if that is what is wanted (as you say, no example given) but I presume PQ can do that. If so, what would happen to C5 if doing that made 4 columns?
I do have code for this but it looks like PQ (which I know nothing about) would be the way to go. It sure was complicated (for me, at least).
Thanks for the information. I don't know PQ. I've passed the problem back to the owner of the spreadsheet
 
Upvote 0
Let me know if you want the code I wrote for this. I might still have it. Note - it separated 1205 from the street name. Not sure if that's what you wanted.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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