Well actually, I thought the first column contains index numbers, 1,2,3 etc. But it seems that was just you showing that the data started from Row 1
So you can use the following lines of code instead of the ones above.
Code:Sub Consolidator() Dim var As Variant, varOut As Variant Dim lng As Long Dim lngRows As Long Dim lngIndex As Long Dim lngSplit As Long var = Range("A1").CurrentRegion.Resize(, 1).Value2 For lngRows = LBound(var) To UBound(var) lng = lng + CLng((UBound(Split(var(lngRows, UBound(var, 2)), ",")) + 2) / 2) Next lngRows ReDim varOut(1 To lng, 1 To 2) lngIndex = 1 For lngRows = LBound(var) To UBound(var) lng = CLng((UBound(Split(var(lngRows, UBound(var, 2)), ",")) + 2) / 2) For lng = lngIndex To lngIndex + lng - 1 lngSplit = lngSplit + 1 varOut(lng, 1) = Split(var(lngRows, UBound(var, 2)) & ",", ",")(lngSplit * 2 - 2) varOut(lng, 2) = Split(var(lngRows, UBound(var, 2)) & ",", ",")(lngSplit * 2 - 1) Next lng lngIndex = lng lngSplit = 0 Next lngRows ActiveSheet.Next.Cells(1).Resize(UBound(varOut), 2).Value = varOut End Sub




Reply With Quote

Bookmarks