Bonsoir le forum, Alexe645698, R@chid, AL 22,
Trouvé sur un autre forum par macro, car au format de cellule ce n'est pas possible.
Mettre les immatriculations à partir de B2 au format aa111aa transformation automatique.
Dans un module standard
Public Function PLAQUE(x As String)
Dim V As New Collection
x = Replace(x, " ", "")
For i = 1 To Len(x)
y = Mid(x, i, 1)
If Not IsNumeric(y) Then
V.Add CStr(y)
Else
V.Add CInt(y)
End If
Next
For j = 1 To V.Count
If TypeName(V.Item(j)) <> TypeName(V.Item(j + 1)) Then
V.Add "-", , , j
j = j + 1
End If
Next
For k = 1 To V.Count
z = z & V.Item(k)
Next
PLAQUE = UCase(z)
End Function
Puis dans le module de la feuille
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Anc As String, Nouv As String
If Target.Column = 2 And Target.Row > 1 And Target.Count = 1 Then
Anc = Target
Nouv = PLAQUE(Anc)
Application.EnableEvents = False
Target = Nouv
End If
Application.EnableEvents = True
End Sub
Ci joint un fichier exemple:
Cordialement.