将行中的单元格中的文本拆分为多行,即可拆分多行

我的问题是对此的扩展, 拆分单元格中的文本 ,其中,我需要拆分单元格中的文本与行分隔成单独的行,不只是一列,但多列。

我的数据的屏幕截图 : 我的数据截图

只是build立在你的链接的答案做了什么:

Sub JustDoIt2() 'working for active sheet 'copy to the end of sheets collection ActiveSheet.Copy after:=Sheets(Sheets.Count) Dim tmpArr As Variant Dim Cell As Range For Each Cell In Range("A2", Range("A2").End(xltoright).End(xlDown)) If InStr(1, Cell, Chr(10)) <> 0 Then tmpArr = Split(Cell, Chr(10)) If Cell.Offset(1) <> Cell Then Cell.EntireRow.Copy Cell.Offset(1, 0).Resize(UBound(tmpArr), 1). _ EntireRow.Insert xlShiftDown End If Cell.Resize(UBound(tmpArr) + 1, 1) = Application.Transpose(tmpArr) End If Next Application.CutCopyMode = False End Sub