Extracting numbers (feet and inches) from cell

jhblack76

New Member
Joined
Nov 30, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I'm trying to extract multiple feet and inches values from a single cell. Have used several iterations of SUBSTITUTE with VALUE((MID(FIND))), but haven't found the right combination for variable length numbers.

In B9: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3,CHAR(39),"[ftwide]",1),CHAR(34),"[inwide]",1),CHAR(120),"[by]",1),CHAR(34),"[indeep]",1),CHAR(39),"[ftdeep]",1),CHAR(45),CHAR(32))
In C9: =MID(B9,FIND("[ftwide]",B9,9)-7,7)
In D9: =MID(B9,FIND("[inwide]",B9,9)-7,7)
In E9: =MID(B9,FIND("[ftdeep]",B9,9)-7,7)
In F9: =MID(B9,FIND("[indeep]",B9,9)-7,7)

Any help is appreciated!

DESIRED OUTPUT
StringSubstituteFeet WideInches WideFeet DeepInches Deep
PGB-1 - 123'-1" x 100.375'-11.625"PGB 1 123[ftwide] 1[inwide] [by] 100.375[ftdeep] 11.625[indeep]123.0001.000100.37511.625
PGB-4 - 18.50" x 84"PGB 4 18.50[inwide] [by] 84[indeep]-18.500-84.000
PGB-9 - 6'-5" x 8'-10"PGB 9 6[ftwide] 5[inwide] [by] 8[ftdeep] 10[indeep]6.0005.0008.00010.000
RESULTS
StringSubstituteFeet WideInches WideFeet DeepInches Deep
PGB-1 - 123'-1" x 100.375'-11.625"PGB 1 123[ftwide] 1[inwide] [by] 100.375[ftdeep] 11.625[indeep]",B9,9)-7,7)] 1 123 wide] 1 ",B9,9)-7,7)]100.375",B9,9)-7,7)]11.625
PGB-4 - 18.50" x 84"PGB 4 18.50[inwide] [by] 84[indeep]#VALUE!",B10,9)-7,7)]18.50#VALUE! [by] 84
PGB-9 - 6'-5" x 8'-10"PGB 9 6[ftwide] 5[inwide] [by] 8[ftdeep] 10[indeep] B 9 6 wide] 5 [by] 8 eep] 10
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Is the format for all of your data consistent with the example? XXX-# - Feet / Inches x Feet / Inches ?

Using the second row as an example, should it remain as 18.5 Inches or be converted to 1 Foot 6.5 Inches?
 
Upvote 0
Fiddling around a little with your example, this appears to work. It may be possible to refine some of the formulas slightly, this was the first set that worked.
Book1
ABCDE
8RESULTS
9StringFeet WideInches WideFeet DeepInches Deep
10PGB-1 - 123'-1" x 100.375'-11.625"1231100.37511.625
11PGB-4 - 18.50" x 84"018.5084
12PGB-9 - 6'-5" x 8'-10"65810
Sheet3
Cell Formulas
RangeFormula
B10:B12B10=LET(s,SEARCH("|",SUBSTITUTE(A10," - "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
C10:C12C10=LET(s,IFERROR(SEARCH("'",A10),SEARCH("|",SUBSTITUTE(A10," - "," | ",1)))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
D10:D12D10=LET(s,SEARCH("|",SUBSTITUTE(A10," x "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
E10:E12E10=LET(s,IFERROR(SEARCH("|",SUBSTITUTE(A10,"'","|",2)),SEARCH("|",SUBSTITUTE(A10," x "," | ",1)))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
 
Upvote 0
Is the format for all of your data consistent with the example? XXX-# - Feet / Inches x Feet / Inches ?

Using the second row as an example, should it remain as 18.5 Inches or be converted to 1 Foot 6.5 Inches?

The beginning of the string (XXX-#) is not consistent. The remainder (feet'-inches" x feet'-inches") will be consistent. I have other cells that will convert inches to feet, etc, so not concerned about that part. Data extraction is main concern.
 
Upvote 0
Fiddling around a little with your example, this appears to work. It may be possible to refine some of the formulas slightly, this was the first set that worked.
Book1
ABCDE
8RESULTS
9StringFeet WideInches WideFeet DeepInches Deep
10PGB-1 - 123'-1" x 100.375'-11.625"1231100.37511.625
11PGB-4 - 18.50" x 84"018.5084
12PGB-9 - 6'-5" x 8'-10"65810
Sheet3
Cell Formulas
RangeFormula
B10:B12B10=LET(s,SEARCH("|",SUBSTITUTE(A10," - "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
C10:C12C10=LET(s,IFERROR(SEARCH("'",A10),SEARCH("|",SUBSTITUTE(A10," - "," | ",1)))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
D10:D12D10=LET(s,SEARCH("|",SUBSTITUTE(A10," x "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
E10:E12E10=LET(s,IFERROR(SEARCH("|",SUBSTITUTE(A10,"'","|",2)),SEARCH("|",SUBSTITUTE(A10," x "," | ",1)))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))

This is fantastic! There will be some cells that have / in them, such as:
PB - S3.04/14 - 12" x 54"

Anything I can add to the formula to strip / out of it so it will read those correctly?
 
Upvote 0
This should fix it, note that the formula in C10 should have a double space between the " " of the second substitute function, sometimes the forum software trims them down to single spaces.
Book1
ABCDE
9StringFeet WideInches WideFeet DeepInches Deep
10PGB-1 - 123'-1" x 100.375'-11.625"1231100.37511.625
11PGB-4 - 18.50" x 84"018.5084
12PGB-9 - 6'-5" x 8'-10"65810
13PB - S3.04/14 - 12" x 54"012054
Sheet3
Cell Formulas
RangeFormula
B10:B13B10=LET(s,SEARCH("|",SUBSTITUTE(A10," - "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
C10:C13C10=LET(s,IFERROR(SEARCH("'",A10),SEARCH("|",SUBSTITUTE(A10," - "," | ",LEN(A10)-LEN(SUBSTITUTE(A10," - "," ")))))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
D10:D13D10=LET(s,SEARCH("|",SUBSTITUTE(A10," x "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
E10:E13E10=LET(s,IFERROR(SEARCH("|",SUBSTITUTE(A10,"'","|",2)),SEARCH("|",SUBSTITUTE(A10," x "," | ",1)))+1,e,SEARCH("|",SUBSTITUTE(A10,"""","|",2)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))
 
Upvote 0
Solution
Brilliant solution. I've spent the entire day on this and you solved it in minutes! Thank you!
 
Upvote 0
Believe it or not this is actually quite a common type of question, although it is usually extracting names or parts of addresses rather than measurements but the basic principles are the same.

Some of the formula may still need a little fine tuning, I haven't tested the string in row 13 with feet and inches, only inches so that may need to be allowed for. Also, I haven't tested with one dimension being in feet and inches with the other in inches only, something I image could be possible if one dimension is less than 12 inches.

I'll keep your thread on my watch list in case you find any problems but fingers crossed all works ok.
 
Upvote 0
I've tested multiple variations and it is working great, even managed to add a third dimension where needed. Thanks again. Have never used LET() before and struggling to understand the syntax. Struggling with another part. Trying to figure out how to adapt your work into another portion that looks like this (I left my old formula attempt showing so you can see the problem I was having).

MarkQtyDia.PenTopSubstituteDia_FPen_FTop_F
A - 18" / 10'-0" / 91'-8.75"21810.0097.25A 18 [india] / / 10 [ftpen] 0 [inpen] / 91 [fttop] 8.75 [intop] ",F2)-2,2),0)]18 ",F2)-2,2)+((MID(F2,FIND(" [inpen] ",F2)-2,2))/12),0)]10.00 ",F2)-2,2)+((MID(F2,FIND(" [intop] ",F2)-2,2))/12),0)]97.25
A - 18" / 10'-0" / 92'-0"71810.0092.00A 18 [india] / / 10 [ftpen] 0 [inpen] / 92 [fttop] 0 [intop] ",F3)-2,2),0)]18 ",F3)-2,2)+((MID(F3,FIND(" [inpen] ",F3)-2,2))/12),0)]10.00 ",F3)-2,2)+((MID(F3,FIND(" [intop] ",F3)-2,2))/12),0)]92.00
A - 18" / 10'-0" / 96'-10"281810.0096.83A 18 [india] / / 10 [ftpen] 0 [inpen] / 96 [fttop] 10 [intop] ",F4)-2,2),0)]18 ",F4)-2,2)+((MID(F4,FIND(" [inpen] ",F4)-2,2))/12),0)]10.00 ",F4)-2,2)+((MID(F4,FIND(" [intop] ",F4)-2,2))/12),0)]96.83
24/60 - 24" / 60'-0" / 88'-0"82460.0088.0024/60 24 [india] / / 60 [ftpen] 0 [inpen] / 88 [fttop] 0 [intop] ",F5)-2,2),0)]24 ",F5)-2,2)+((MID(F5,FIND(" [inpen] ",F5)-2,2))/12),0)]60.00 ",F5)-2,2)+((MID(F5,FIND(" [intop] ",F5)-2,2))/12),0)]88.00
24/60 - 24" / 60'-0" / 90'-11.5"142460.0090.0424/60 24 [india] / / 60 [ftpen] 0 [inpen] / 90 [fttop] 11.5 [intop] ",F6)-2,2),0)]24 ",F6)-2,2)+((MID(F6,FIND(" [inpen] ",F6)-2,2))/12),0)]60.00 ",F6)-2,2)+((MID(F6,FIND(" [intop] ",F6)-2,2))/12),0)]90.04
24/60 - 24" / 60'-0" / 90'-6"72460.0090.5024/60 24 [india] / / 60 [ftpen] 0 [inpen] / 90 [fttop] 6 [intop] ",F7)-2,2),0)]24 ",F7)-2,2)+((MID(F7,FIND(" [inpen] ",F7)-2,2))/12),0)]60.00 ",F7)-2,2)+((MID(F7,FIND(" [intop] ",F7)-2,2))/12),0)]90.50


The data is typically well-formatted, but varies project-to-project.
 
Upvote 0
Have never used LET() before and struggling to understand the syntax.
It's actually quite simple once you figure it out. It's not necessary to use LET, and any formula written with it can be written without. Using it makes things much easier and makes the formula shorter when large sections are repeated.

Taking the first formula from earlier, s is simply a name given to the section in bold and e a name given to the section in italic
=LET(s,SEARCH("|",SUBSTITUTE(A10," - "," | ",1))+1,e,SEARCH("|",SUBSTITUTE(A10,"'","|",1)),IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0))

This means in the last part, IFERROR(--TRIM(MID(A10,s+1,e-s-1)),0) which is the actual formula, you can use s and e to shorten it instead of repeating the whole section again.
Although e was only use once, so it was not strictly necessary to use a name for it, I find it can make it easier for fine tuning formulas like this.

I'll try and have a look at the new data set later today and see what I can do with it.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

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