Public Sub textToColumns()
Ange ARange = Range("A:A")
Ange BRange = Range("B:B")
Ställ in CRange = Range("C:C")
Ställ in DRange = Range("D:D")
Dim arr() Som sträng
lr = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set out = Arbetsblad. Lägg till
out.Name = "ut"
outRow = 2
För i = 2 Till lr
arr = Split(ARange(i), ","")
För j = 0 Till UBound(arr)
out.Cells(outRow, 1) = Trim(arr(j))
out.Cells(outRow, 2) = BRange(i)
out.Cells(outRow, 3) = CRange(i)
out.Cells(outRow, 4) = Drange(i)
outRow = outRow + 1
Nästa j
Nästa jag
End Sub
Jag gjorde inte rubrikerna eller hanterade utdataarket ordentligt men du kan se i princip vad som händer.