Need formula to break up column

Sm3tUser

New Member
Joined
Apr 13, 2015
Messages
11
I posted yesterday, but I'm back with another issue. I need my document to look like this:


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Suburb[/TD]
[TD]State[/TD]
[TD]Postcode[/TD]
[/TR]
[TR]
[TD]Surry Hills[/TD]
[TD]NSW[/TD]
[TD]2011[/TD]
[/TR]
[TR]
[TD]Maroubra[/TD]
[TD]VIC[/TD]
[TD]3041[/TD]
[/TR]
</tbody>[/TABLE]


At the moment however, it looks like this:


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Address[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Beverly Hills NSW 2076[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bondi ACT 5607[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I can't use Text to Columns because then it would split suburbs that have two words up as well. Eg.


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Address[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Beverly[/TD]
[TD]Hills[/TD]
[TD]NSW[/TD]
[TD]6033[/TD]
[/TR]
</tbody>[/TABLE]


So, I need a formula that follows the following conditions:


- If the cell has 4 words/pieces of text, then split the column after the second space
- If the cell has 3 words/pieces of text, then split the column after the first space


It should look like this:


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Suburb[/TD]
[TD]State/Postcode[/TD]
[/TR]
[TR]
[TD]Alexandria[/TD]
[TD]NSW 1092[/TD]
[/TR]
[TR]
[TD]Surry Hills[/TD]
[TD]VIC 1039[/TD]
[/TR]
</tbody>[/TABLE]


Afterwards, I will just use Text to Columns to split up the State/Postcode box, so no need to worry about that. The end result should be the first table in my post.


I appreciate any and all help - thanks!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try

Suburb =LEFT(A1,LEN(A1)-9)
State =LEFT(RIGHT(A1,8),3)
Postcode =RIGHT(A1,4)
 
Upvote 0
Too lazy to write a shorter formula.

=LEFT(A2,FIND("~",SUBSTITUTE(A2," ","~",LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))-1))-1)
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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