Text to Columns based on character pattern

reganshaw

Board Regular
Joined
May 6, 2005
Messages
77
Hi All,

I have been given a data set that was poorly converted from a pdf file which I'm left trying to clean up.

All of the data is in column A and each line of data is in a single cell.
Example:

A1: A1A# ST. JOHN'S NL STN MAIN B1G DOMINION NS STN MAIN B3Z TANTALLON NS STN MAIN
A2: J1S WINDSOR QC SUCC BUREAU-CHEF J4K LONGUEUIL QC SUCC BUREAU-CHEF J7E BOISBRIAND QC SUCC DEPOT RIVE-NORD J1T ASBESTOS QC SUCC BUREAU-CHEF

I'd like to split the string in each cell at every occurrence of a letter+number+letter grouping. So A1 would be split into 3 columns;
  • A1A# ST. JOHN'S NL STN MAIN
  • B1G DOMINION NS STN MAIN
  • B3Z TANTALLON NS STN MAIN
B1 would be split into 4 columns;
  • J1S WINDSOR QC SUCC BUREAU-CHEF
  • J4K LONGUEUIL QC SUCC BUREAU-CHEF
  • J7E BOISBRIAND QC SUCC DEPOT RIVE-NORD
  • J1T ASBESTOS QC SUCC BUREAU-CHEF

Any thoughts?
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

Are there possibly any other Numbers in between each Letter-Number-Letter ?
 
Upvote 0
Also... tried to update the original problem explanation but it didn’t post.

In the examples given, I incorrectly said cell B1 - I should have said cell A2.
All of the data is in column A.
 
Upvote 0
Hi,

Are there possibly any other Numbers in between each Letter-Number-Letter ?

Each Letter-Number-Letter occurrence could contain any single digit number between 0 and 9.

My question was, in between Each Letter-Number-Letter, is it possible there are other Numbers, like "A1A something 2 something else A2B"

Assuming there isn't, this Long formula will work, formula copied down and across as far as needed or until you see Blanks:


Book1
ABCDEF
1A1A# ST. JOHN'S NL STN MAIN B1G DOMINION NS STN MAIN B3Z TANTALLON NS STN MAINA1A# ST. JOHN'S NL STN MAINB1G DOMINION NS STN MAINB3Z TANTALLON NS STN MAIN
2J1S WINDSOR QC SUCC BUREAU-CHEF J4K LONGUEUIL QC SUCC BUREAU-CHEF J7E BOISBRIAND QC SUCC DEPOT RIVE-NORD J1T ASBESTOS QC SUCC BUREAU-CHEFJ1S WINDSOR QC SUCC BUREAU-CHEFJ4K LONGUEUIL QC SUCC BUREAU-CHEFJ7E BOISBRIAND QC SUCC DEPOT RIVE-NORDJ1T ASBESTOS QC SUCC BUREAU-CHEF
Sheet533
Cell Formulas
RangeFormula
B1=IFERROR(MID($A1,FIND("@",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1&"xx|","0","|"),"1","|"),"2","|"),"3","|"),"4","|"),"5","|"),"6","|"),"7","|"),"8","|"),"9","|"),"|","@",COLUMNS($B1:B1)))-1,FIND("^",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1&"xx|","0","|"),"1","|"),"2","|"),"3","|"),"4","|"),"5","|"),"6","|"),"7","|"),"8","|"),"9","|"),"|","^",COLUMNS($B1:B1)+1))-FIND("@",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1&"xx|","0","|"),"1","|"),"2","|"),"3","|"),"4","|"),"5","|"),"6","|"),"7","|"),"8","|"),"9","|"),"|","@",COLUMNS($B1:B1)))-1),"")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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