2015-10-21 74 views

回答

2

只是建立在什麼在你的鏈接的答案做:

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