1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Sub Split_Cell()
Dim nbcar_init, nbcar_end, Nb_int, Nb_space, j, k, a, b, z, y, r As Long
Dim i As Long
Dim cell_interm As String
LastRow = ThisWorkbook.Sheets("Output").Cells(Rows.Count, 2).End(xlUp).Row
j = 1
k = 0
a = 1
z = 1
y = 10
r = 2
While Cells(a, 3) <> ""
Cells(a, 4) = Cells(a, 3) & Chr(10)
a = a + 1
Wend
'Columns("C:C").Delete Shift:=xlToLeft
ThisWorkbook.Sheets("Output").Range("A1:E" & LastRow).ClearContents
While Cells(j, 3) <> ""
nbcar_init = Len(Cells(j, 3)) ' BASIC DATA
nbcar_end = Len(Replace(Cells(j, 3), Chr(10), ""))
Nb_space = (nbcar_init - nbcar_end)
cell_interm = Cells(j, 3)
i = 2
For i = (1 + k) To (Nb_space + k)
Sheets("Output").Cells(i, 1) = Sheets("Input").Cells(z, 1) ' Column 1
Sheets("Output").Cells(i, 2) = y 'Column 2
Sheets("Output").Cells(i, 3) = Left(cell_interm, InStr(1, cell_interm, Chr(10))) 'Column 3
Nb_int = Len(cell_interm) - InStr(1, cell_interm, Chr(10))
cell_interm = Right(cell_interm, Nb_int)
y = y + 10
'ICI
'Sheets("Output").Cells(i, 4).Formula = "=RIGHT(RC[-2],LEN(RC[-2])-SEARCH("":"",RC[-2],1))" 'COLONNE E
'Sheets("Output").Cells(i, 5).Formula = "=TRIM(RC[-1])" 'COLONNE F
'Sheets("Output").Cells(i, 6).Formula = "=RC[-6]&""/""&RC[-5]" 'COLONNE G
Next
j = j + 1
k = k + Nb_space
z = z + 1
y = 10
i = i + 1
Wend
'Columns("C:C").Delete Shift:=xlToLeft
End Sub |