Split cell and name columns

megadentalda

New Member
Joined
Jan 30, 2017
Messages
22
Hello,
Firstly hope everyone is staying sfae.

I have a list of excel rows with cells like this:
Product ID: 3943, Product Qty: 1, Product SKU: LPFL-B, Product Name: Gloves Latex Powder Free Size Large (BLOSSOM), Product Weight: 0.0000, Product Variation Details: , Product Unit Price: 14.95, Product Total Price: 14.95|Product ID: 12491, Product Qty: 1, Product SKU: Opwil1, Product Name: Optim 33 Disinfectant Wipes 160/Can, Product Weight: 1.0000, Product Variation Details: , Product Unit Price: 29.95, Product Total Price: 29.95

to be clear the above is all in one cell.

I need to create columns with headers "Product ID", "Product Qty", "Product Name" etc with the content of cell being "3943", "LPFL-B", "Gloves Latex Powder Free Size Large (BLOSSOM)" etc. but also if there is a "|"will need to insert a line and copy everything down 1 cell and then separate into columns as above....

any help with this will be very appreciative.

thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
A few questions to begin with
how did you get this data in to excel
what was the original source of this data
is this a one off exercise or going to be repeated
is it always the same number of columns or is there instances of missing data, if so is it blank or does it still contain the header but no data
 
Upvote 0
Is this what you are looking for:
Book1
ABCDEFGH
1Product ID Product Qty Product SKU Product Name Product Weight Product Variation Details Product Unit Price Product Total Price
23943
31
4 LPFL-B
5 Gloves Latex Powder Free Size Large (BLOSSOM)
60
7
814.95
9 14.95|Product ID
101
11 Opwil1
12 Optim 33 Disinfectant Wipes 160/Can
131
14
1529.95
1629.95
Sheet2


Created using Power Query.

VBA Code:
Mcode:  
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column1", Splitter.SplitTextByDelimiter(",", 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.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type2",{"Column1.3"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 0, 1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Column1.1]), "Column1.1", "Column1.2"),
    #"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
    #"Removed Columns1"
 
Upvote 0
Is this what you are looking for:
Book1
ABCDEFGH
1Product ID Product Qty Product SKU Product Name Product Weight Product Variation Details Product Unit Price Product Total Price
23943
31
4 LPFL-B
5 Gloves Latex Powder Free Size Large (BLOSSOM)
60
7
814.95
9 14.95|Product ID
101
11 Opwil1
12 Optim 33 Disinfectant Wipes 160/Can
131
14
1529.95
1629.95
Sheet2


Created using Power Query.

VBA Code:
Mcode: 
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column1", Splitter.SplitTextByDelimiter(",", 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.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type2",{"Column1.3"}),
    #"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 0, 1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Column1.1]), "Column1.1", "Column1.2"),
    #"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
    #"Removed Columns1"
almost there. need everything in 1 row. until we see the "|" which then brings everything after in next line. b/c its next SKU. i notice for 2nd SKU there is nothing in 1st column and also in last column the word "product ID" still showed up in the cell....

would love a vba code for this because client does not have latest version of excel so do not believe they ave access to power query
 
Upvote 0
A few questions to begin with
how did you get this data in to excel
what was the original source of this data
is this a one off exercise or going to be repeated
is it always the same number of columns or is there instances of missing data, if so is it blank or does it still contain the header but no data
1) it is an export for a ecommerce website
2) no it will be constantly repeated which is why i am looking for a vba code, if one off would just spend the manula time of doing it myself...
3) always same number columns will have data header but no data afetr it.. just a ","

thanks
 
Upvote 0
hello

thanks for the help... but i have ended up finding a seperate way of exporting the orders which gets this done for me automatically.

thank you for the offer to help!!
 
Upvote 0
client does not have latest version of excel so do not believe they ave access to power query

FYI: PQ has been around since Excel Version 2010. So at least 10 years.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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