formula or macro to extract a code in the format “03 30 00” from various text data in multiple variations

ebrandt

Board Regular
Joined
Dec 13, 2010
Messages
54
I need a formula or macro that can extract a code in the format “03 30 00” from various data in text format in multiple variations, such as;


  • “033000 CAST-IN-PLACE CONCRETE”
  • “Section 03 30 00 CAST-IN-PLACE CONCRETE”
  • “03 30 00 CAST-IN-PLACE CONCRETE”
  • “ 03 3000 CAST-IN-PLACE CONCRETE” with a leading blank space or spaces
  • Section 03 3000 - CAST-IN-PLACE CONCRETE
  • Section 12 3661.19 - Quartz Agglomerate Countertops (here I would want “12 36 61”)

The code numbers and text will vary and the codes could begin with numbers between “00” through “50” and sometimes will have more than 6 numbers, but I am just trying to extract the first 6 numbers with the two blank spaces in the format “xx xx xx”.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

Would this help:


Book1
AB
1033000 CAST-IN-PLACE CONCRETE03 30 00
2Section 03 30 00 CAST-IN-PLACE CONCRETE03 30 00
303 30 00 CAST-IN-PLACE CONCRETE03 30 00
4Section 03 3 - CAST-IN-PLACE CONCRETE
5 03 3000 CAST-IN-PLACE CONCRETE with a leading blank space or spaces03 30 00
6Section 03 3000 - CAST-IN-PLACE CONCRETE03 30 00
7Section 12 3661.19 - Quartz Agglomerate Countertops (here I would want 12 36 61)12 36 61
Sheet187
Cell Formulas
RangeFormula
B1=IFERROR(TEXT(MID(SUBSTITUTE(A1," ",""),MIN(FIND({0,1,2,3,4,5},SUBSTITUTE(A1," ","")&"012345")),6)+0,"00 00 00"),"")


Formula copied down.
 
Upvote 0
You're welcome, glad it works for you.
 
Upvote 0
Is there a similar formula that would eliminate all of the extraneous text at the beginning of each item and leave me with everything else............ie: "12 3661.19 - Quartz Agglomerate Countertops" or "03 30 00 CAST-IN-PLACE CONCRETE"?
 
Upvote 0
Not entirely sure what you mean, do you mean like Column C below?


Book1
ABC
1033000 CAST-IN-PLACE CONCRETE03 30 00033000 CAST-IN-PLACE CONCRETE
2Section 03 30 00 CAST-IN-PLACE CONCRETE03 30 0003 30 00 CAST-IN-PLACE CONCRETE
303 30 00 CAST-IN-PLACE CONCRETE03 30 0003 30 00 CAST-IN-PLACE CONCRETE
4Section 03 3 - CAST-IN-PLACE CONCRETE03 3 - CAST-IN-PLACE CONCRETE
503 3000 CAST-IN-PLACE CONCRETE03 30 0003 3000 CAST-IN-PLACE CONCRETE
6Section 03 3000 - CAST-IN-PLACE CONCRETE03 30 0003 3000 - CAST-IN-PLACE CONCRETE
7Section 12 3661.19 - Quartz Agglomerate Countertops12 36 6112 3661.19 - Quartz Agglomerate Countertops
Sheet187
Cell Formulas
RangeFormula
B1=IFERROR(TEXT(MID(SUBSTITUTE(A1," ",""),MIN(FIND({0,1,2,3,4,5},SUBSTITUTE(A1," ","")&"012345")),6)+0,"00 00 00"),"")
C1=MID(A1,MIN(FIND({0,1,2,3,4,5},A1&"012345")),255)


Formula copied down.
 
Upvote 0
You're welcome, glad it worked for you.

Consequently, if you do Column C, then you can Extract the 6 digit code from Column C with a simpler formula like below:


Book1
ABCD
1033000 CAST-IN-PLACE CONCRETE03 30 00033000 CAST-IN-PLACE CONCRETE03 30 00
2Section 03 30 00 CAST-IN-PLACE CONCRETE03 30 0003 30 00 CAST-IN-PLACE CONCRETE03 30 00
303 30 00 CAST-IN-PLACE CONCRETE03 30 0003 30 00 CAST-IN-PLACE CONCRETE03 30 00
4Section 03 3 - CAST-IN-PLACE CONCRETE03 3 - CAST-IN-PLACE CONCRETE
503 3000 CAST-IN-PLACE CONCRETE03 30 0003 3000 CAST-IN-PLACE CONCRETE03 30 00
6Section 03 3000 - CAST-IN-PLACE CONCRETE03 30 0003 3000 - CAST-IN-PLACE CONCRETE03 30 00
7Section 12 3661.19 - Quartz Agglomerate Countertops12 36 6112 3661.19 - Quartz Agglomerate Countertops12 36 61
Sheet187
Cell Formulas
RangeFormula
B1=IFERROR(TEXT(MID(SUBSTITUTE(A1," ",""),MIN(FIND({0,1,2,3,4,5},SUBSTITUTE(A1," ","")&"012345")),6)+0,"00 00 00"),"")
C1=MID(A1,MIN(FIND({0,1,2,3,4,5},A1&"012345")),255)
D1=IFERROR(TEXT(LEFT(SUBSTITUTE(C1," ",""),6)+0,"00 00 00"),"")
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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