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
| Function Repart(C As Range, NumCol As Integer) As String
Dim i As Integer, Ctr As Integer
Dim Rub() As String, Temp As String
Dim Bip As Integer
Application.Volatile
ReDim Preserve Rub(0)
For i = 1 To Len(C.Value)
If IsNumeric(Mid(C.Value, i, 1)) Then
Temp = Temp & Mid(C.Value, i, 1)
Bip = 1
ElseIf Not IsNumeric(Mid(C.Value, i, 1)) And Bip = 0 Then
Temp = Temp & Mid(C.Value, i, 1)
ElseIf Not IsNumeric(Mid(C.Value, i, 1)) And Bip = 1 Then
Rub(UBound(Rub)) = Temp
Temp = ""
Bip = 0
ReDim Preserve Rub(UBound(Rub) + 1)
Temp = Temp & Mid(C.Value, i, 1)
End If
Next i
Select Case NumCol
Case 1: Repart = Rub(0)
Case 2: Repart = Rub(1)
Case 3: Repart = Temp
End Select
End Function |
Partager