Separate number from text

sean1541

New Member
Joined
Feb 14, 2023
Messages
31
Office Version
  1. 2016
Platform
  1. MacOS
Hi I want to separate the number from the text
using 2016 excel


Potatoes Prepared 162kg
Potatoes Prepared
162kg


Book1
ABCDE
1
2Potatoes Prepared 162kg
3Carrots Diced 80kg
4Bananas - box 92kg
5Spanish Onions - bag 10kg
6Lettuce 35 Heads
7Stir Fry Veg Mix - bag 25kg
8Mixed Peppers - box 1kg
9Mushrooms - carton 11kg
10Leeks - bag 5kg
11Tomatoes 20kg
12
13Turnips - Diced 80kg
14Potatoes Prepared 10kg
15Garlic Strings 1kg
16Stir Fry Veg Mix - bag 25kg
17Cauliflower 3 Heads
18Broccoli 6kg
19Coleslaw Mix 15kg
20
21
Inventory
 
separating Bag Box etc

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Split Column by Character Transition", "Column1.1", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column1.1.1", "Column1.1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1.1", type text}, {"Column1.1.2", type text}, {"Column1.2", type text}})
in
    #"Changed Type1"

Potatoes Prepared 162kg
Carrots Diced 80kg
Bananas box 92kg
Spanish Onions bag 10kg
Lettuce 35 Heads
Stir Fry Veg Mix bag 25kg
Mixed Peppers box 1kg
Mushrooms carton 11kg
Leeks bag 5kg
Tomatoes 20kg
Turnips Diced 80kg
Potatoes Prepared 10kg
Garlic Strings 1kg
Stir Fry Veg Mix bag 25kg
Cauliflower 3 Heads
Broccoli 6kg
Coleslaw Mix 15kg
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi is there a way to extract bag, box etc into a separate column.
With formulas, is this what you are after?

23 03 04.xlsm
ABCD
1
2Potatoes Prepared 162kgPotatoes Prepared 162kg
3Carrots Diced 80kgCarrots Diced 80kg
4Bananas - box 92kgBananasbox92kg
5Spanish Onions - bag 10kgSpanish Onionsbag10kg
6Lettuce 35 HeadsLettuce 35 Heads
7Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
8Mixed Peppers - box 1kgMixed Peppersbox1kg
9Mushrooms - carton 11kgMushroomscarton11kg
10Leeks - bag 5kgLeeksbag5kg
11Tomatoes 20kgTomatoes 20kg
12    
13Turnips - Diced 80kgTurnipsDiced80kg
14Potatoes Prepared 10kgPotatoes Prepared 10kg
15Garlic Strings 1kgGarlic Strings 1kg
16Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
17Cauliflower 3 HeadsCauliflower 3 Heads
18Broccoli 6kgBroccoli 6kg
19Coleslaw Mix 15kgColeslaw Mix 15kg
Split (2)
Cell Formulas
RangeFormula
B2:B19B2=TRIM(IF(ISNUMBER(FIND("-",A2)),LEFT(A2,FIND("-",A2)-1),SUBSTITUTE(A2,D2,"")))
C2:C19C2=TRIM(SUBSTITUTE(REPLACE(A2,1,FIND("-",A2&"-"),""),D2,""))
D2:D19D2=TRIM(MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890)),20))


With CreateObject("VBScript.RegExp")
Sorry it is working my fault
Does that mean that you are not using MacOS per your profile, or perhaps that you have Windows as well?
 
Upvote 0
With formulas, is this what you are after?

23 03 04.xlsm
ABCD
1
2Potatoes Prepared 162kgPotatoes Prepared 162kg
3Carrots Diced 80kgCarrots Diced 80kg
4Bananas - box 92kgBananasbox92kg
5Spanish Onions - bag 10kgSpanish Onionsbag10kg
6Lettuce 35 HeadsLettuce 35 Heads
7Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
8Mixed Peppers - box 1kgMixed Peppersbox1kg
9Mushrooms - carton 11kgMushroomscarton11kg
10Leeks - bag 5kgLeeksbag5kg
11Tomatoes 20kgTomatoes 20kg
12    
13Turnips - Diced 80kgTurnipsDiced80kg
14Potatoes Prepared 10kgPotatoes Prepared 10kg
15Garlic Strings 1kgGarlic Strings 1kg
16Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
17Cauliflower 3 HeadsCauliflower 3 Heads
18Broccoli 6kgBroccoli 6kg
19Coleslaw Mix 15kgColeslaw Mix 15kg
Split (2)
Cell Formulas
RangeFormula
B2:B19B2=TRIM(IF(ISNUMBER(FIND("-",A2)),LEFT(A2,FIND("-",A2)-1),SUBSTITUTE(A2,D2,"")))
C2:C19C2=TRIM(SUBSTITUTE(REPLACE(A2,1,FIND("-",A2&"-"),""),D2,""))
D2:D19D2=TRIM(MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890)),20))




Does that mean that you are not using MacOS per your profile, or perhaps that you have Windows as well?


Thanks a million for your help this works great
Can I expand it down the row ?
 
Upvote 0
Thanks again works great.
Good news. (y)

BTW, this has a simpler formula for column B and still seems to do the job.

23 03 04.xlsm
ABCD
1
2Potatoes Prepared 162kgPotatoes Prepared 162kg
3Carrots Diced 80kgCarrots Diced 80kg
4Bananas - box 92kgBananasbox92kg
5Spanish Onions - bag 10kgSpanish Onionsbag10kg
6Lettuce 35 HeadsLettuce 35 Heads
7Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
8Mixed Peppers - box 1kgMixed Peppersbox1kg
9Mushrooms - carton 11kgMushroomscarton11kg
10Leeks - bag 5kgLeeksbag5kg
11Tomatoes 20kgTomatoes 20kg
12    
13Turnips - Diced 80kgTurnipsDiced80kg
14Potatoes Prepared 10kgPotatoes Prepared 10kg
15Garlic Strings 1kgGarlic Strings 1kg
16Stir Fry Veg Mix - bag 25kgStir Fry Veg Mixbag25kg
17Cauliflower 3 HeadsCauliflower 3 Heads
18Broccoli 6kgBroccoli 6kg
19Coleslaw Mix 15kgColeslaw Mix 15kg
Split (3)
Cell Formulas
RangeFormula
B2:B19B2=TRIM(SUBSTITUTE(LEFT(A2,FIND("-",A2&"-")-1),D2,""))
C2:C19C2=TRIM(SUBSTITUTE(REPLACE(A2,1,FIND("-",A2&"-"),""),D2,""))
D2:D19D2=TRIM(MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890)),20))
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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