How to extract value within cells, and automatically convert them as new row?

superjoejoe

New Member
Joined
Jul 2, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hello,

  1. There are multiple data within each cell
  2. Each is separated by "|"
  3. Need to extract each data & automatically generate new row
  4. Final result is: each row contains 1 data only
Thank you
 

Attachments

  • WhatsApp Image 2020-07-01 at 18.48.23.jpeg
    WhatsApp Image 2020-07-01 at 18.48.23.jpeg
    93.5 KB · Views: 19

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
with Power Query
RawRaw
http://url1.jpg | http://url2.jpg | http://url3.jpg | http://url4.jpg | http://url5.jpghttp://url1.jpg
http://url6.jpg | http://url7.jpghttp://url2.jpg
http://url8.jpg | http://url9.jpg | http://url10.jpg | http://url11.jpghttp://url3.jpg
http://url12.jpghttp://url4.jpg
http://url5.jpg
http://url6.jpg
http://url7.jpg
http://url8.jpg
http://url9.jpg
http://url10.jpg
http://url11.jpg
http://url12.jpg

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Split = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Raw", Splitter.SplitTextByDelimiter(" | ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Raw")
in
    Split
 
Upvote 0
Welcome to the MrExcel board!

Each is separated by "|"
Your image looks more like the data is separated by " | " & my suggestions are based on the spaces being there. If they are not, modifications can be made.

Provided your data is not too large (TEXTJOIN has a limit for the resultant string of 32,767 characters) you could try this formula approach

20 07 03.xlsm
AB
1
2http://url1.jpg | http://url2.jpg | http://url3.jpg | http://url4.jpg | http://url5.jpghttp://url1.jpg
3http://url6.jpg | http://url7.jpghttp://url2.jpg
4http://url8.jpg | http://url9.jpg | http://url10.jpg | http://url11.jpghttp://url3.jpg
5http://url12.jpghttp://url4.jpg
6http://url5.jpg
7http://url6.jpg
8http://url7.jpg
9http://url8.jpg
10http://url9.jpg
11http://url10.jpg
12http://url11.jpg
13http://url12.jpg
14 
Convert
Cell Formulas
RangeFormula
B2:B14B2=TRIM(LEFT(SUBSTITUTE(REPLACE("|"&TEXTJOIN(" | ",1,A$2:A$5)&" | ",1,FIND("#",SUBSTITUTE(" | "&TEXTJOIN(" | ",1,A$2:A$5)&" | "," | ","#",ROWS(B$2:B2))),"")," | ",REPT(" ",500)),500))



Alternatively, for the same layout, you could try this macro. This also has a limit - but much larger.

VBA Code:
Sub SplitIt()
  Dim a As Variant
 
  With Range("A2", Range("A" & Rows.Count).End(xlUp))
    a = Split(Join(Application.Transpose(.Value), " | "), " | ")
    .Offset(, 1).Resize(UBound(a) + 1).Value = Application.Transpose(a)
  End With
End Sub
 
Upvote 0
Another =TRIM(MID(SUBSTITUTE(TEXTJOIN("|",,$A$2:$A$5),"|",REPT(" ",255)),ROWS($C$4:C4)*255-254,255))
Without further modification, that one is limited. For example, we only have to add another row or two of data or even another few urls in an existing cell and strange results start to appear.

Example
20 07 03.xlsm
ABC
1
2http://url1.jpg | http://url2.jpg | http://url3.jpg | http://url4.jpg | http://url5.jpg
3http://url6.jpg | http://url7.jpg
4http://url8.jpg | http://url9.jpg | http://url10.jpg | http://url11.jpghttp://url1.jpg
5http://url12.jpg | http://urla.jpg | http://urlb.jpg | http://urlc.jpg | http://urld.jpghttp://url2.jpg
6http://url3.jpg
7http://url4.jpg
8http://url5.jpg
9http://url6.jpg
10http://url7.jpg
11http://url8.jpg
12http://url9.jpg
13http://url10.jpg
14http://url11.jpg
15http://url12.jpg
16http://urla.jpg
17http://urlb.jpg
18http://urlc.jpg
19htt
20p://urld.jpg
21 
Convert (3)
Cell Formulas
RangeFormula
C4:C21C4=TRIM(MID(SUBSTITUTE(TEXTJOIN("|",,$A$2:$A$5),"|",REPT(" ",255)),ROWS($C$4:C4)*255-254,255))



You could increase the 255/254 values to extend somewhat but if the actual data is at all large you will then run the risk of exceeding TEXTJOIN's result character limit. Hence the approach that I took. The formula is a little longer but it will handle a much larger set of data.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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