Split out data from a cell to new rows.

jon110763

New Member
Joined
Oct 17, 2013
Messages
16
Hi, I have a spreadsheet that has multiple rows and in 1 column there is multiple numbers separated by a comma, in the row. I need the numbers to be separated into new rows, keeping the integrity of the original rows.
The total rows vary from day to day and the amount of numbers in col D varies with each row.
How someone can help me.
Ask for any more info as necessary
Thanks
Jon

Original spreadsheet.
London123456Apple123456,123457,123458,123459
Dallas654321Orange123460,123461
Paris162534Black123465,123467,123469
Desired result
London123456Apple123456
123457
123458
123459
Dallas654321Orange123460
123461
Paris162534Black123465
123467
123469
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Making sure that column D is text, try this:

Code:
Sub SplitInsert()
    Dim r As Range
    Dim a As Variant
    Sheets("Sheet1").Range("D:D").NumberFormat = "@"
    For Each r In Range("D:D")
        If r.Value Like "*,*" Then
            Debug.Print True
            a = Split(r.Value, ",")
            r.Offset(1, 0).Resize(UBound(a)).EntireRow.Insert Shift:=xlDown
            For i = LBound(a) To UBound(a)
                r.Offset(i, 0).Value = a(i)
            Next i
        End If
    Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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