Extracting data from a string

richardthelionheart

Board Regular
Joined
Mar 25, 2016
Messages
95
Office Version
  1. 2016
Platform
  1. Windows
A7 31 . 13
A8 30 . 32
A5 * 30 . 41
A9 30 . 66
A8 * 30 . 06
A6 30 . 51

I have data which is formatted in a strange way.
There are spaces where you would not need or expect them to be.
Also there are some with * which is annoying because they are not
standardized to make it easy to extract the data in columns.
I want the data to look like this -
A7 31.13
A8 30.32
A5 30.66
A8 30.06
A6 30.51

Using a number of columns, I could probably find a way.
That would be cumbersome and untidy.
Maybe there's a neat solution to this using just one
formula ?? (or two)
Any help would be greatly appreciated.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try
Code:
=TRIM(SUBSTITUTE(A1,"*",""))
 
Upvote 0
Here is a Power Query solution

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","*","",Replacer.ReplaceText,{"Column1"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Column1", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Changed Type1",{{"Column1.1", Text.Clean, type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Cleaned Text",{{"Column1.2", Text.Trim, type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Trimmed Text",{"Column1.1", "Column1.2"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged")
in
    #"Merged Columns"


which is longer and more convoluted than the suggestions already offered with formula
 
Last edited:
Upvote 0
a little shorter :)

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Replace1 = Table.ReplaceValue(Source,"*","",Replacer.ReplaceText,{"src"}),
    Replace2 = Table.ReplaceValue(Replace1," ","",Replacer.ReplaceText,{"src"}),
    Type = Table.TransformColumnTypes(Replace2,{{"src", type number}})
in
    Type[/SIZE]

or even like this:
Code:
[SIZE=1]
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Replace = Table.ReplaceValue(Table.ReplaceValue(Source,"*","",Replacer.ReplaceText,{"src"})," ","",Replacer.ReplaceText,{"src"}),
    Type = Table.TransformColumnTypes(Replace,{{"src", type number}})
in
    Type[/SIZE]
 
Last edited:
Upvote 0
How about

=LEFT(A2,3)&SUBSTITUTE(SUBSTITUTE(MID(A2,4,LEN(A2))," ",""),"*","")
 
Upvote 0
Many thanks to all contributors for giving up your time to solve this problem. I really appreciate it, Richard.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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