Need help extracting a substring

126driver

New Member
Joined
Mar 25, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I don't know why I can't figure this out. I have the following text string in cell A2:

162780 162780 DECAL PUMP 5X4 7/16 DCL082B EA 750 750

I need to extract the last "750" and second to last "750" to separate cells. There is always a "EA" within the string before these counts (which are quantity ordered and quantity shipped). I have the formula: =MID($A2,SEARCH("EA",$A2)+3,3) to extract the "750" after "EA" right now, but the issue is that these counts are not always three digits, could be 1 - 4, always separated by a space. I know I need to insert additional formula instead of "+3" probably using SUBSTITUTE but I've searched and have hit a roadblock. Any help is tremendously appreciated and if anyone can point me to a good resource to learn more about LEFT, RIGHT, SUBSTITUTE, MID and LEN that would also be appreciated. Any suggested courses on the subject?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Power Query
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByEachDelimiter({"EA "}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column1.2", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.2.1", "Column1.2.2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter1",{"Column1.1"})
in
    #"Removed Columns"

Book2
ABCD
2Column1Column1.2.1Column1.2.2
3162780 162780 DECAL PUMP 5X4 7/16 DCL082B EA 750 750750750
Sheet1
 
Upvote 0
Another option, using formula: in A2
Excel Formula:
=LET(aSPLIT,TEXTSPLIT(A2,"EA "),bSplit,TEXTSPLIT(INDEX(aSPLIT,1,COLUMNS(aSPLIT))," "),--bSplit)

Cartel1
ABC
1
2162780 162780 DECAL PUMP 5X4 7/16 DCL082B EA 750 750750750
3
Foglio1
Cell Formulas
RangeFormula
B2:C2B2=LET(aSPLIT,TEXTSPLIT(A2,"EA "),bSplit,TEXTSPLIT(INDEX(aSPLIT,1,COLUMNS(aSPLIT))," "),--bSplit)
Dynamic array formulas.
 
Upvote 0
Are there always 10 "fields" ? If so, how about:

Code:
=INDEX(TEXTSPLIT(A1," "),,{9,10})
 
Upvote 0
Thanks for all of the help! I'm unknowledgeable in Power Query - need to check that out. Other options worked perfectly. @kweaver, I'm not sure if the fields will vary, both of your solutions worked too. Thanks!
 
Upvote 0
Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0
TextBefore.xlsm
ABCD
1
2162780 162780 DECAL PUMP 5X4 7/16 DCL082B EA 750 750 750750
3162780 162780 DECAL PUMP 5X4 7/16 DCL082B EA 7502 750275027502
4
2b
Cell Formulas
RangeFormula
B2:D2B2=TEXTSPLIT(TEXTAFTER(A2,"EA")," ")
B3B3=TEXTBEFORE(TEXTAFTER(A3,"EA ")," ")
C3C3=TEXTAFTER(TEXTAFTER(A3,"EA ")," ")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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