Devide cell values based on new line

Pontos

Board Regular
Joined
Mar 26, 2003
Messages
132
I have a table with 2 columns.
I would like to divide all the values in column B into new row based on the char(10) end of line.

Sample table - before:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Product code[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]110/1[/TD]
[TD]- manual operation
- high voltage
- yellow color
- email notification
[/TD]
[/TR]
[TR]
[TD]110/2[/TD]
[TD]- automatic operation
- low voltage
- red color
- SMS notification
[/TD]
[/TR]
</tbody>[/TABLE]

Sample table - after:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Product code[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]110/1[/TD]
[TD]- manual operation
[/TD]
[/TR]
[TR]
[TD]110/1[/TD]
[TD]- high voltage
[/TD]
[/TR]
[TR]
[TD]110/1[/TD]
[TD]- yellow color
[/TD]
[/TR]
[TR]
[TD]110/1[/TD]
[TD]- email notification[/TD]
[/TR]
[TR]
[TD]110/2[/TD]
[TD]- automatic operation
[/TD]
[/TR]
[TR]
[TD]110/2[/TD]
[TD]- low voltage[/TD]
[/TR]
[TR]
[TD]110/2[/TD]
[TD]- red color[/TD]
[/TR]
[TR]
[TD]110/2[/TD]
[TD]- SMS notification[/TD]
[/TR]
</tbody>[/TABLE]

Any ideas?

Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try :
Code:
Sub FT()
Dim rng As Range, cel As Range, r As Variant, s&
Application.ScreenUpdating = False
[A:B].Insert
Set rng = Range([D2], Cells(Rows.Count, "D").End(xlUp))
For Each cel In rng
    r = Split(cel, Chr(10))
    s = UBound(r) - LBound(r) + 1
    With Cells(Rows.Count, "B").End(xlUp)
        .Item(2).Resize(s).Value = Application.Transpose(r)
        .Item(2, 0).Resize(s).Value = cel(1, 0)
    End With
Next
[C:D].Delete
Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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