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
| Option Base 1
Sub chaine()
Dim dl As Long, ch, x As Long, tb1, tb2(), tb3(), z As Long, y As Long, a As Integer
dl = Range("C" & Rows.Count).End(xlUp).Row
tb1 = Range("C3:C" & dl)
For x = 1 To UBound(tb1)
ch = Split(tb1(x, 1))
For y = 0 To UBound(ch)
If ch(y) Like "*-*" Then
z = z + 1
ReDim Preserve tb2(1 To z)
tb2(z) = ch(y)
Exit For
End If
Next y
If UBound(ch) > y Then
On Error Resume Next
For a = y + 1 To UBound(ch)
If ch(a) Like "*-*" Then
If Err = 0 Then
ReDim Preserve tb3(1 To z)
tb3(z) = ch(a)
Err.Clear
Exit For
End If
End If
Next a
End If
Next x
Range("D3:D" & z + 1) = WorksheetFunction.Transpose(tb2)
Range("E3:E" & z + 1) = WorksheetFunction.Transpose(tb3)
End Sub |
Partager