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
| Dim LastLig As Long, i As Long
Dim N As Integer, M As Integer
Dim TypSte As String, BdSte As String
Application.ScreenUpdating = False
BdSte = " SARL _ SASU _ EURL _ SA _ M _ MME _ MLLE " 'Mettre tous les type de sociétés séparés par " _ " espace underscore expace
With Sheets("Feuil1") 'Adapter le nom de la feuille
LastLig = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 3 To LastLig
N = InStr(Trim(.Range("A" & i).Value), " ")
M = InStrRev(Trim(.Range("A" & i).Value), " ")
If N > 0 Then
TypSte = Left(.Range("A" & i).Value, N - 1)
If InStr(BdSte, TypSte) > 0 Then
.Range("B" & i).Value = TypSte
.Range("A" & i).Value = Mid(.Range("A" & i).Value, N + 1)
Else
If M > 0 Then
TypSte = Mid(.Range("A" & i).Value, M + 1)
If InStr(BdSte, TypSte) > 0 Then
.Range("B" & i).Value = TypSte
.Range("A" & i).Value = Left(.Range("A" & i).Value, M - 1)
End If
End If
End If
End If
Next i
End With |
Partager