Sub tst()
Dim X As Variant
Dim iIndex As Integer
iIndex = 1
For i = 1 To WorksheetFunction.CountA(Worksheets("Sheet2").Range("B:B")) + 1
If Range("B" & i).Value = "" Then Exit For
X = Split(Range("B" & i).Value, Chr(10))
Range("D" & iIndex).Resize(UBound(X) - LBound(X) + 1).Value = Application.Transpose(X)
'For j = iIndex To iIndex + UBound(X)
' Range("C" & j).Value = Range("A" & i).Value
' Next
iIndex = iIndex + UBound(X) + 1
Next
End Sub
VB Macro to split data in single cell into multiple rows. Assumptions 1: Data in the row is split by "Alt + Enter", Assumption 2: Data to be split is available in column B
No comments:
Post a Comment