Hi Peter, I started working on the same but gave up when I arrived at that same ugly result. I'm sure (not really, but I'm a believer) there is a way to read the records within those rows and have them extracted in a structured way.This would start the process off if you have access to Power Query.
Because I am new at this, I had to look up the syntax "#(lf)" for line-feed.
Yes, a split column at first colon delimiter will do the trick. Then remove the "header" columns. That is where it becomes cumbersome. The number of columns may vary, and thus the pattern may not apply to new data.@GraH - Guido
It must be possible to remove text from the start of each field up to and including the first 'colon'. Regrettably, my knowledge of M is not up to the task!
Since then, maybe this is progress!
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}, {"Column11", type any}, {"Column12", type any}, {"Column13", type any}, {"Column14", type any}, {"Column15", type any}, {"Column16", type any}, {"Column17", type any}, {"Column18", type any}, {"Column19", type any}, {"Column20", type any}, {"Column21", type any}, {"Column22", type any}, {"Column23", type any}, {"Column24", type any}, {"Column25", type any}, {"Column26", type any}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Column1"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([Column1] <> null)),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Filtered Rows", {{"Column1", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1", type text}}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Column1", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.1", type text}, {"Column1.2", type text}}),
#"Transposed Table" = Table.Transpose(#"Changed Type2"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type3" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date/Time", type text}, {"ame", type text}, {"Job Title", type text}, {"Compay", type text}, {"City", type text}, {"Phoe", type text}, {"Email", type text}, {"Product Lie", type text}, {"Re", type text}})
in
#"Changed Type3"
(CellValue)=>
let
#"Converted to Table" = #table(1, {{CellValue}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Converted to Table", {{"Column1", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1", type text}}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Column1", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.1", type text}, {"Column1.2", type text}}),
#"Transposed Table" = Table.Transpose(#"Changed Type2"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type3" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date/Time", type text}, {"ame", type text}, {"Job Title", type text}, {"Compay", type text}, {"City", type text}, {"Phoe", type text}, {"Email", type text}, {"Product Lie", type text}, {"Re", type text}})
in
#"Changed Type3"
let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type any}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type any}, {"Column10", type any}, {"Column11", type any}, {"Column12", type any}, {"Column13", type any}, {"Column14", type any}, {"Column15", type any}, {"Column16", type any}, {"Column17", type any}, {"Column18", type any}, {"Column19", type any}, {"Column20", type any}, {"Column21", type any}, {"Column22", type any}, {"Column23", type any}, {"Column24", type any}, {"Column25", type any}, {"Column26", type any}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Column1"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Convert", each FxPattern([Column1])),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Column1] <> null)),
#"Expanded Convert" = Table.ExpandTableColumn(#"Filtered Rows", "Convert", {"Date/Time", "ame", "Job Title", "Compay", "City", "Phoe", "Email", "Product Lie", "Re"}, {"Date/Time", "ame", "Job Title", "Compay", "City", "Phoe", "Email", "Product Lie", "Re"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Convert",{"Column1"})
in
#"Removed Columns"
nitika.manhas
It would the best to get 'better' Sheet1 or
at least all of those should be in same format!
= all Sheet2 headers do not match with Sheet1 data.
With formulas,
You could test to do as in Sample Sheet2 - so manually!
but .. step 1 is to 'Convert to Range' ...
With Marco, it'll be also possible
but still Sheet2 headers won't match!
The letter N was typed too may times, thus the key board starts failigI suspect the differences are largely due to an editor with a vendetta against the letter 'N'. Correcting the source data may be the best answer.
CTRL + H, about only 6 timesPeter Bartholomew
Correcting source ...
To correct ~500 cells ... manually ...
that time would use for something else!
It's much better to ask/get data, which has clear logic.
'cause or effect' ... 'egg or chicken'
A formula solution.
1] To adjusted Row 3 header and to use custom cell format to B3, D3, F3 and H3 in meet with the "Sheet 1" input data.
2] Define a range name "ConcatenateData", please check with Name Manage for details
3] In "Sheet2" A4 copied across and down :
=IFERROR(MID(LEFT(ConcatenateData,IF(B$3="",399,SEARCH(B$3,ConcatenateData)-1)),SEARCH(A$3,ConcatenateData)+LEN(A$3),399),"")
Regards
Bosco