c = 9 ' =>調整每格字數 lastrow = Sheets("工作表1").Range("a1").CurrentRegion.Rows.Count r = 2 For i = 2 To lastrow If Len(Cells(r, 1)) > c Then addrow = WorksheetFunction.RoundUp(Len(Cells(r, 1)) / c, 0) - 1 temp = Cells(r, 1) Cells(r, 1) = Mid(temp, 1, c)
For j = 1 To addrow r = r + 1 '預設只修改A、B,2個欄位 Range(Cells(r, 1), Cells(r, 2)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Cells(r, 1) = Mid(temp, j * c + 1, c)