EXTRACT specific text into next cell

makinmomb

Active Member
Joined
Dec 23, 2013
Messages
401
I have this on cell A1

NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT

I want to extract the word 60 x 60 into cell B1
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Maybe this:

Code:
In B1

=IFERROR(TRIM(MID(REPT(" ",LEN(A1))&SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),SEARCH(" X ",REPT(" ",LEN(A1))&SUBSTITUTE(A1," ",REPT(" ",LEN(A1))))-2*LEN(A1),4*LEN(A1))),"")

Markmzz
 
Upvote 0
Try

=MID(A1,15,7)

Yeah will work for the following

GEMMA 30 X 44 = MURANO BEIGE
GEMMA 30 X 44 = MURANO BROWN
GEMMA 42 X 42 = MURANO BEIGE
GEMMA 42 X 42 = MURANO BROWN

but does not work with following

NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT
NIRO REGAL 60 X 60 = GMR 81 LIGHT GREY
<colgroup><col width="297" style="width: 223pt; mso-width-source: userset; mso-width-alt: 10861;"> <tbody> </tbody>


<colgroup><col width="363" style="width: 272pt; mso-width-source: userset; mso-width-alt: 13275;"> <tbody> </tbody>
 
Upvote 0
Markmzzz , Yes works not sure why does not did not copy for the 3rd cell

NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT60 X 60
NIRO REGAL 60 X 60 = GMR 81 LIGHT GREY60 X 60
NIRO LUCIDO 60 X 60 = GMA 33 ABREE
<colgroup><col width="297" style="width: 223pt; mso-width-source: userset; mso-width-alt: 10861;"> <col width="64" style="width: 48pt;"> <tbody> </tbody>
 
Upvote 0
What about a UDF
Place in a standard module and use
Code:
=wd(A1)

Code:
Function wd(s As String) As String ' handy for extracting item dimensions
With CreateObject("VBScript.RegExp")
  .Pattern = "(\b[0-9]{2,}\s[X]\s[0-9]{2,}\b)" 
  If .Test(s) Then wd = .Execute(s)(0).SubMatches(0)
End With
End Function











Excel 2003
ABC
1GEMMA 30 X 44 = MURANO BEIGE30 X 44
2GEMMA 30 X 44 = MURANO BROWN30 X 44
3GEMMA 42 X 42 = MURANO BEIGE42 X 42
4GEMMA 42 X 42 = MURANO BROWN42 X 42
5NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT60 X 60
6NIRO REGAL 60 X 60 = GMR 81 LIGHT GREY60 X 60
Sheet1
Cell Formulas
RangeFormula
C1=wd(A1)
C2=wd(A2)
C3=wd(A3)
C4=wd(A4)
C5=wd(A5)
C6=wd(A6)
 
Upvote 0
Markmzzz , Yes works not sure why does not did not copy for the 3rd cell

NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT60 X 60
NIRO REGAL 60 X 60 = GMR 81 LIGHT GREY60 X 60
NIRO LUCIDO 60 X 60 = GMA 33 ABREE

<tbody>
</tbody>

No problem here. Look at this:

Layout

NIRO CEMENTUM 60 X 60 GCM 01 WHITE MATT60 X 60
NIRO REGAL 60 X 60 = GMR 81 LIGHT GREY60 X 60
NIRO LUCIDO 60 X 60 = GMA 33 ABREE60 X 60
GEMMA 30 X 44 = MURANO BEIGE30 X 44
GEMMA 30 X 44 = MURANO BROWN30 X 44
GEMMA 42 X 42 = MURANO BEIGE42 X 42
GEMMA 42 X 42 = MURANO BROWN42 X 42
*************************************************

<tbody>
</tbody>


Formula

Code:
In A1

=IFERROR(TRIM(MID(REPT(" ",LEN(A1))&SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),SEARCH(" X ",REPT(" ",LEN(A1))&SUBSTITUTE(A1," ",REPT(" ",LEN(A1))))-2*LEN(A1),4*LEN(A1))),"")

And copy down.
Markmzz
 
Upvote 0
This formula seems to work also (change each of the FIND functions to SEARCH functions if the X can be either upper or lower)...

Code:
In A1...

=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND(" X ",A1)-1)," ",REPT(" ",99)),99))&" X "&REPLACE(LEFT(A1,FIND(" ",A1,FIND(" X ",A1)+3)-1),1,FIND(" X ",A1)+2,"")

Copy down as needed
Note: Because this formula does not use IFERROR, it will also work in XL2003 and below (if that should be a consideration).
 
Last edited:
Upvote 0
A small modification in my formula:

Code:
=TRIM(MID(SUBSTITUTE(" "&A1," ",REPT(" ",LEN(A1))),SEARCH(" X ",SUBSTITUTE(" "&A1," ",REPT(" ",LEN(A1)))&" X ")-2*LEN(A1),4*LEN(A1)))

Markmzz
 
Upvote 0
A small modification in my formula:

Code:
=TRIM(MID(SUBSTITUTE(" "&A1," ",REPT(" ",LEN(A1))),SEARCH(" X ",SUBSTITUTE(" "&A1," ",REPT(" ",LEN(A1)))&" X ")-2*LEN(A1),4*LEN(A1)))
I am not sure I would call that a "small modification", but I like the resulting formula that you got from it. Nice!
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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