EXCEL VBA - Column to rows after split
Macro code split a cell value with ; and insert into rows in another sheet
Sub setData()
Dim insertRow As Integer
Dim srcRow As Integer
insertRow=1
row=Worksheets("Sheet1").Range("A1").End(xlDown).Row
For srcRow=1 To row
textToSplit=Worksheets("Sheet1").Cells(srcRow,2).Value
splitList=split(textToSplit,";")
splitListLength=UBound(splitList)
For j = 1 To splitListLength+1
Worksheets("Sheet2").Cells(insertRow,2).Value=splitList(j-1)
Worksheets("Sheet2").Cells(insertRow,1).Value=Worksheets("Sheet1").Cells(srcRow,1).Value
insertRow=insertRow+1
Next j
Next srcRowEnd Sub
Comments
Post a Comment