Forum Discussion
akjha2
Aug 03, 2024Copper Contributor
Splitting data in one cell into separate rows
Hi all, I want to automatically split the 3rd column so that each row only has one number in the 3rd column. Is there a way to do this without manually splitting each row? I am currently doing i...
OliverScheurich
Aug 03, 2024Gold Contributor
Sub split_data()
Dim i, j, k As Long
Dim str() As String
Range("E:G").Clear
For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
str = Split(Cells(i, 3).Value, ",")
For j = LBound(str, 1) To UBound(str, 1)
k = k + 1
Cells(k, 5).Value = Cells(i, 1).Value
Cells(k, 6).Value = Cells(i, 2).Value
Cells(k, 7).Value = str(j)
Next j
Next i
End Sub
In e.g. Excel 2013 you can run this macro when you click the button in cell I1.