Splitting a single rows data into multiple rows

santanuKD

New Member
Joined
Jun 12, 2009
Messages
12
Hi -

Need is to split the data in Cell "J" to multiple rows along with other column Data.

Cell Data should be moved to other Rows when the Line starts with Key Word "Step".

Please suggest. Attaching the file for reference.


on a new sheet:
Code:
Sub SplitData()
    Dim arrColC As Variant
    Dim shDATA As Worksheet
    Dim r As Long, c As Long, i As Long
    
    Set shDATA = Sheets("Data Sheet") 'change as needed
    
    Application.DisplayAlerts = False
    On Error Resume Next
    Sheets("SPLIT SHEET").Delete
    On Error GoTo 0
    Application.DisplayAlerts = True
    Sheets.Add After:=shDATA
    ActiveSheet.Name = "SPLIT SHEET"
    
    i = 1
    For r = 1 To shDATA.Cells(Rows.Count, "A").End(xlUp).Row
        arrColC = Split(shDATA.Cells(r, 3), ",")
        For c = 0 To UBound(arrColC)
            Cells(i, 1) = shDATA.Cells(r, 1)
            Cells(i, 2) = Format(shDATA.Cells(r, 2), "d-mmm-yy")
            Cells(i, 3) = arrColC(c)
            i = i + 1
        Next c
    Next r
End Sub

Split from https://www.mrexcel.com/forum/excel...to-multiple-rows-post3177907.html#post3177907
 
Last edited by a moderator:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,555
Messages
5,832,448
Members
430,135
Latest member
Xefi

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
Top